[PATCH v2 1/2] powerpc/pseries: Do not pass an error pointer to of_node_put() in pSeries_reconfig_add_node()

Markus Elfring Markus.Elfring at web.de
Tue Mar 21 21:33:56 AEDT 2023


Date: Tue, 21 Mar 2023 10:30:23 +0100

It can be determined in the implementation of the function
“pSeries_reconfig_add_node” that an error code would occasionally
be provided by a call of a function like pseries_of_derive_parent().
This error indication was passed to an of_node_put() call according to
an attempt for exception handling so far.

Thus fix the risk for undesirable software behaviour by using
an additional label for this error case.

Link: https://lists.ozlabs.org/pipermail/linuxppc-dev/2023-March/256025.html
Link: https://lore.kernel.org/lkml/87pm9377qt.fsf@linux.ibm.com/
Reported-by: Nathan Lynch <nathanl at linux.ibm.com>
Fixes: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 ("Linux-2.6.12-rc2")
Signed-off-by: Markus Elfring <elfring at users.sourceforge.net>
---
V2:
This update step was added according to another change request.

 arch/powerpc/platforms/pseries/reconfig.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c
index 599bd2c78514..44f8ebc2ec0d 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -40,7 +40,7 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist
     np->parent = pseries_of_derive_parent(path);
     if (IS_ERR(np->parent)) {
         err = PTR_ERR(np->parent);
-        goto out_err;
+        goto free_name;
     }
 
     err = of_attach_node(np);
@@ -56,6 +56,7 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist
 out_err:
     if (np) {
         of_node_put(np->parent);
+free_name:
         kfree(np->full_name);
         kfree(np);
     }
--
2.40.0




More information about the Linuxppc-dev mailing list