Skip to content

Commit f3ddbaa

Browse files
ivecerakuba-moo
authored andcommitted
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. Fixes: 9431063 ("dpll: core: Add DPLL framework base functions") Signed-off-by: Ivan Vecera <ivecera@redhat.com> Reviewed-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com> Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Link: https://patch.msgid.link/20260121130012.112606-1-ivecera@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 27880b0 commit f3ddbaa

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

drivers/dpll/dpll_core.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ dpll_xa_ref_pin_add(struct xarray *xa_pins, struct dpll_pin *pin,
8383
if (ref->pin != pin)
8484
continue;
8585
reg = dpll_pin_registration_find(ref, ops, priv, cookie);
86-
if (reg) {
87-
refcount_inc(&ref->refcount);
88-
return 0;
89-
}
86+
if (reg)
87+
return -EEXIST;
9088
ref_exists = true;
9189
break;
9290
}
@@ -164,10 +162,8 @@ dpll_xa_ref_dpll_add(struct xarray *xa_dplls, struct dpll_device *dpll,
164162
if (ref->dpll != dpll)
165163
continue;
166164
reg = dpll_pin_registration_find(ref, ops, priv, cookie);
167-
if (reg) {
168-
refcount_inc(&ref->refcount);
169-
return 0;
170-
}
165+
if (reg)
166+
return -EEXIST;
171167
ref_exists = true;
172168
break;
173169
}

0 commit comments

Comments
 (0)