]> git.baikalelectronics.ru Git - kernel.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:30 +0000 (11:41 +0100)
[ Upstream commit 4bb0d047c1d8315fcfab4f900ac48b41cf372595 ]

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: d0520f5cec74 ("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
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/misc/cxl/pci.c

index 0ac3f4cb88acb5c349cc688be29f96e6d702785b..d183836d80e3f0d634cca1d79694ddba04e1292f 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;
        }