public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] dpll: Prevent duplicate registrations
@ 2026-01-21 13:00 Ivan Vecera
  2026-01-21 13:37 ` Kubalewski, Arkadiusz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ivan Vecera @ 2026-01-21 13:00 UTC (permalink / raw)
  To: netdev
  Cc: Vadim Fedorenko, Arkadiusz Kubalewski, Jiri Pirko,
	David S. Miller, Michal Michalik, Milena Olech, open list

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.

Fixes: 9431063ad323 ("dpll: core: Add DPLL framework base functions")
Signed-off-by: Ivan Vecera <ivecera@redhat.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 a461095efd8a..8879a7235156 100644
--- a/drivers/dpll/dpll_core.c
+++ b/drivers/dpll/dpll_core.c
@@ -83,10 +83,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;
 	}
@@ -164,10 +162,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.52.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH net] dpll: Prevent duplicate registrations
  2026-01-21 13:00 [PATCH net] dpll: Prevent duplicate registrations Ivan Vecera
@ 2026-01-21 13:37 ` Kubalewski, Arkadiusz
  2026-01-21 17:18 ` Vadim Fedorenko
  2026-01-22 16:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Kubalewski, Arkadiusz @ 2026-01-21 13:37 UTC (permalink / raw)
  To: Vecera, Ivan, netdev@vger.kernel.org
  Cc: Vadim Fedorenko, Jiri Pirko, David S. Miller, Michal Michalik,
	Olech, Milena, open list

>From: Ivan Vecera <ivecera@redhat.com>
>Sent: Wednesday, January 21, 2026 2:00 PM
>
>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.
>
>Fixes: 9431063ad323 ("dpll: core: Add DPLL framework base functions")
>Signed-off-by: Ivan Vecera <ivecera@redhat.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 a461095efd8a..8879a7235156 100644
>--- a/drivers/dpll/dpll_core.c
>+++ b/drivers/dpll/dpll_core.c
>@@ -83,10 +83,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;
> 	}
>@@ -164,10 +162,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.52.0

Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] dpll: Prevent duplicate registrations
  2026-01-21 13:00 [PATCH net] dpll: Prevent duplicate registrations Ivan Vecera
  2026-01-21 13:37 ` Kubalewski, Arkadiusz
@ 2026-01-21 17:18 ` Vadim Fedorenko
  2026-01-22 16:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Vadim Fedorenko @ 2026-01-21 17:18 UTC (permalink / raw)
  To: Ivan Vecera, netdev
  Cc: Arkadiusz Kubalewski, Jiri Pirko, David S. Miller,
	Michal Michalik, Milena Olech, open list

On 21/01/2026 13:00, Ivan Vecera wrote:
> 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.
> 
> Fixes: 9431063ad323 ("dpll: core: Add DPLL framework base functions")
> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
> ---
>   drivers/dpll/dpll_core.c | 12 ++++--------
>   1 file changed, 4 insertions(+), 8 deletions(-)

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] dpll: Prevent duplicate registrations
  2026-01-21 13:00 [PATCH net] dpll: Prevent duplicate registrations Ivan Vecera
  2026-01-21 13:37 ` Kubalewski, Arkadiusz
  2026-01-21 17:18 ` Vadim Fedorenko
@ 2026-01-22 16:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-22 16:20 UTC (permalink / raw)
  To: Ivan Vecera
  Cc: netdev, vadim.fedorenko, arkadiusz.kubalewski, jiri, davem,
	michal.michalik, milena.olech, linux-kernel

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 21 Jan 2026 14:00:11 +0100 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net] dpll: Prevent duplicate registrations
    https://git.kernel.org/netdev/net/c/f3ddbaaaaf4d

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-22 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-21 13:00 [PATCH net] dpll: Prevent duplicate registrations Ivan Vecera
2026-01-21 13:37 ` Kubalewski, Arkadiusz
2026-01-21 17:18 ` Vadim Fedorenko
2026-01-22 16:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox