]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
cxl: Fix refcount leak in cxl_calc_capp_routing
authorMiaoqian Lin <linmq006@gmail.com>
Sun, 5 Jun 2022 06:00:38 +0000 (10:00 +0400)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 24 Nov 2022 12:12:19 +0000 (23:12 +1100)
of_get_next_parent() returns a node pointer with refcount incremented,
we should use of_node_put() on it when not need anymore.
This function only calls of_node_put() in normal path,
missing it in the error path.
Add missing of_node_put() to avoid refcount leak.

Fixes: f24be42aab37 ("cxl: Add psl9 specific code")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Acked-by: Andrew Donnellan <ajd@linux.ibm.com>
Acked-by: Frederic Barrat <fbarrat@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220605060038.62217-1-linmq006@gmail.com
drivers/misc/cxl/pci.c

index 3de0aea62ade4bbc33bf50250da5783e30f15319..62385a529d86986e228dde8be2e96aeaaf44fabd 100644 (file)
@@ -387,6 +387,7 @@ int cxl_calc_capp_routing(struct pci_dev *dev, u64 *chipid,
        rc = get_phb_index(np, phb_index);
        if (rc) {
                pr_err("cxl: invalid phb index\n");
+               of_node_put(np);
                return rc;
        }