]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dpll: fix stale iteration in dpll_pin_on_pin_unregister()
authorGrzegorz Nitka <grzegorz.nitka@intel.com>
Sun, 7 Jun 2026 18:30:35 +0000 (20:30 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 13 Jun 2026 20:24:32 +0000 (13:24 -0700)
Neither parent->dpll_refs nor pin->dpll_refs on its own is a correct
iteration target at unregister time:

  - pin->dpll_refs includes DPLLs the child was registered against
    via a different parent or directly; blind unregister WARNs on
    the cookie miss in dpll_xa_ref_pin_del().
  - parent->dpll_refs reflects the parent's current attachments, not
    those at child-register time. Another driver may have (un)reg'd
    the parent against additional DPLLs in the meantime, so we miss
    registrations that exist and visit DPLLs that have none.

Walk pin->dpll_refs and use dpll_pin_registration_find() to filter
to entries whose cookie is this parent. Symmetric with
dpll_pin_on_pin_register(), correct under any subsequent change to
parent->dpll_refs.

Fixes: 9431063ad323 ("dpll: core: Add DPLL framework base functions")
Signed-off-by: Grzegorz Nitka <grzegorz.nitka@intel.com>
Link: https://patch.msgid.link/20260607183045.1213735-4-grzegorz.nitka@intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/dpll/dpll_core.c

index 6dc7e93ece7501bbe3398bb52e43086f241293a9..cea7e2be2cbcdf2e8efb4e708d97b7ebb9ab604d 100644 (file)
@@ -1031,14 +1031,19 @@ EXPORT_SYMBOL_GPL(dpll_pin_on_pin_register);
 void dpll_pin_on_pin_unregister(struct dpll_pin *parent, struct dpll_pin *pin,
                                const struct dpll_pin_ops *ops, void *priv)
 {
+       struct dpll_pin_registration *reg;
        struct dpll_pin_ref *ref;
        unsigned long i;
 
        mutex_lock(&dpll_lock);
        dpll_pin_delete_ntf(pin);
        dpll_xa_ref_pin_del(&pin->parent_refs, parent, ops, priv, pin);
-       xa_for_each(&pin->dpll_refs, i, ref)
+       xa_for_each(&pin->dpll_refs, i, ref) {
+               reg = dpll_pin_registration_find(ref, ops, priv, parent);
+               if (!reg)
+                       continue;
                __dpll_pin_unregister(ref->dpll, pin, ops, priv, parent);
+       }
        mutex_unlock(&dpll_lock);
 }
 EXPORT_SYMBOL_GPL(dpll_pin_on_pin_unregister);