[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251215203037.1324945-10-ivecera@redhat.com>
Date: Mon, 15 Dec 2025 21:30:34 +0100
From: Ivan Vecera <ivecera@...hat.com>
To: netdev@...r.kernel.org
Cc: Alexander Lobakin <aleksander.lobakin@...el.com>,
Andrew Lunn <andrew+netdev@...n.ch>,
Arkadiusz Kubalewski <arkadiusz.kubalewski@...el.com>,
Conor Dooley <conor+dt@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Grzegorz Nitka <grzegorz.nitka@...el.com>,
Jakub Kicinski <kuba@...nel.org>,
Jiri Pirko <jiri@...nulli.us>,
Jonathan Lemon <jonathan.lemon@...il.com>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Leon Romanovsky <leon@...nel.org>,
Mark Bloch <mbloch@...dia.com>,
Michal Schmidt <mschmidt@...hat.com>,
Paolo Abeni <pabeni@...hat.com>,
Petr Oros <poros@...hat.com>,
Prathosh Satish <Prathosh.Satish@...rochip.com>,
Przemek Kitszel <przemyslaw.kitszel@...el.com>,
Richard Cochran <richardcochran@...il.com>,
Rob Herring <robh@...nel.org>,
Saeed Mahameed <saeedm@...dia.com>,
Simon Horman <horms@...nel.org>,
Stefan Wahren <wahrenst@....net>,
Tariq Toukan <tariqt@...dia.com>,
Tony Nguyen <anthony.l.nguyen@...el.com>,
Vadim Fedorenko <vadim.fedorenko@...ux.dev>,
Willem de Bruijn <willemb@...gle.com>,
devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org,
intel-wired-lan@...ts.osuosl.org,
linux-rdma@...r.kernel.org
Subject: [PATCH RFC net-next v2 09/12] dpll: Prevent duplicate registrations
Modify the internal registration helpers dpll_xa_ref_{dpll,pin}_add()
to reject duplicate registration attempts.
Previously, if a caller attempted to register the same pin multiple
times (with the same ops, priv, and cookie) on the same device, the core
silently increments the reference count and return success. This behavior
is incorrect because if the caller makes these duplicate registrations
then for the first one dpll_pin_registration is allocated and for others
the associated dpll_pin_ref.refcount is incremented. During the first
unregistration the associated dpll_pin_registration is freed and for
others WARN is fired.
Fix this by updating the logic to return `-EEXIST` if a matching
registration is found to enforce a strict "register once" policy.
Signed-off-by: Ivan Vecera <ivecera@...hat.com>
---
drivers/dpll/dpll_core.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c
index 88cc3752bd057..e1d884c8fb2bb 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -160,10 +160,8 @@ dpll_xa_ref_pin_add(struct xarray *xa_pins, struct dpll_pin *pin,
if (ref->pin != pin)
continue;
reg = dpll_pin_registration_find(ref, ops, priv, cookie);
- if (reg) {
- refcount_inc(&ref->refcount);
- return 0;
- }
+ if (reg)
+ return -EEXIST;
ref_exists = true;
break;
}
@@ -243,10 +241,8 @@ dpll_xa_ref_dpll_add(struct xarray *xa_dplls, struct dpll_device *dpll,
if (ref->dpll != dpll)
continue;
reg = dpll_pin_registration_find(ref, ops, priv, cookie);
- if (reg) {
- refcount_inc(&ref->refcount);
- return 0;
- }
+ if (reg)
+ return -EEXIST;
ref_exists = true;
break;
}
--
2.51.2
Powered by blists - more mailing lists