cxl: Fix refcount leak in cxl_calc_capp_routing
PATCH 1/1 cxl: Fix refcount leak in cxl_calc_capp_routing
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.
--- drivers/misc/cxl/pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/misc/cxl/pci.c +1 -0
@@ -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; }
Signature · 1 line
2.25.1
Quoted 8 lines · Miaoqian Lin
of_get_next_parent()returns a node pointer with refcount incremented, we should useof_node_put()on it when not need anymore. This function only callsof_node_put()in normal path, missing it in the error path.
Add missingof_node_put()to avoid refcount leak.Fixes f24be42aab37 ("cxl: Add psl9 specific code")Signed-off-by Miaoqian Lin <[email protected]>
Indeed. Thanks!
Fred
Quoted 16 lines
--- drivers/misc/cxl/pci.c | 1 + 1 file changed, 1 insertion(+)drivers/misc/cxl/pci.c +1
-0@@ -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; }
Quoted 9 lines · Miaoqian Lin
of_get_next_parent()returns a node pointer with refcount incremented,
we should useof_node_put()on it when not need anymore. This function only callsof_node_put()in normal path, missing it in the error path.
Add missingof_node_put()to avoid refcount leak.Fixes f24be42aab37 ("cxl: Add psl9 specific code")Signed-off-by Miaoqian Lin <[email protected]>
Thanks!
Quoted 17 lines
---
drivers/misc/cxl/pci.c | 1 +1 file changed, 1 insertion(+)drivers/misc/cxl/pci.c +1
-0@@ -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; }
Should this be applied by Bjorn as most recent changes to that file ?
Le 14/06/2022 à 12:12, Andrew Donnellan a écrit :
Quoted 34 lines · Miaoqian Lin
Quoted 9 lines
of_get_next_parent()returns a node pointer with refcount incremented,
we should useof_node_put()on it when not need anymore. This function only callsof_node_put()in normal path, missing it in the error path.
Add missingof_node_put()to avoid refcount leak.Fixes f24be42aab37 ("cxl: Add psl9 specific code")Signed-off-by Miaoqian Lin <[email protected]>Thanks!
Acked-by Andrew Donnellan <[email protected]>Quoted 17 lines
--- drivers/misc/cxl/pci.c | 1 + 1 file changed, 1 insertion(+)drivers/misc/cxl/pci.c +1
-0@@ -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; }
Quoted 1 line · Christophe Leroy
Should this be applied by Bjorn as most recent changes to that file ?
We usually take cxl patches through powerpc, though sometimes Greg picks them up through char-misc.
Signature · 2 lines
Andrew Donnellan OzLabs, ADL Canberra [email protected] IBM Australia Limited
Michael Ellerman
AppliedQuoted 8 lines · Miaoqian Lin
of_get_next_parent()returns a node pointer with refcount incremented, we should useof_node_put()on it when not need anymore. This function only callsof_node_put()in normal path, missing it in the error path.
Add missingof_node_put()to avoid refcount leak.[...]
Applied to powerpc/next.
[1/1] cxl: Fix refcount leak in cxl_calc_capp_routing
https://git.kernel.org/powerpc/c/1d09697ff22908ae487fc8c4fbde1811732be523
cheers