linux/drivers/dpll
Ivan Vecera 236a657422 dpll: Prevent duplicate registrations
[ Upstream commit f3ddbaaaaf ]

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: 9431063ad3 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-01-30 10:32:21 +01:00
..
zl3073x dpll: zl3073x: Fix output pin registration 2025-10-28 18:54:48 -07:00
dpll_core.c dpll: Prevent duplicate registrations 2026-01-30 10:32:21 +01:00
dpll_core.h dpll: add reference sync get/set 2025-06-27 16:38:02 -07:00
dpll_netlink.c dpll: fix device-id-get and pin-id-get to return errors properly 2025-10-28 17:50:18 -07:00
dpll_netlink.h dpll: add reference sync get/set 2025-06-27 16:38:02 -07:00
dpll_nl.c dpll: add phase-offset-avg-factor device attribute to netlink spec 2025-09-29 18:57:41 -07:00
dpll_nl.h dpll: add reference-sync netlink attribute 2025-06-27 16:38:02 -07:00
Kconfig dpll: Add basic Microchip ZL3073x support 2025-07-09 19:08:52 -07:00
Makefile dpll: Add basic Microchip ZL3073x support 2025-07-09 19:08:52 -07:00