parse_node() looks the node up with of_find_node_by_phandle(), which
returns it with a reference, and do_add_property(),
do_remove_property() and do_update_property() never put that
reference. Every property command written to /proc/powerpc/ofdt leaks
one. Put it when the command is done.

Fixes: 610d91511f99 ("[PATCH] powerpc: Add support for changing properties from 
userspace")
Signed-off-by: Christian Brauner (Amutable) <[email protected]>
---
 arch/powerpc/platforms/pseries/reconfig.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/reconfig.c 
b/arch/powerpc/platforms/pseries/reconfig.c
index 18e3f1a036e3..5a0c9c0b6253 100644
--- a/arch/powerpc/platforms/pseries/reconfig.c
+++ b/arch/powerpc/platforms/pseries/reconfig.c
@@ -271,8 +271,8 @@ static char *parse_node(char *buf, size_t bufsize, struct 
device_node **npp)
 
 static int do_add_property(char *buf, size_t bufsize)
 {
+       struct device_node *np __free(device_node) = NULL;
        struct property *prop = NULL;
-       struct device_node *np;
        unsigned char *value;
        char *name, *end;
        int length;
@@ -296,7 +296,7 @@ static int do_add_property(char *buf, size_t bufsize)
 
 static int do_remove_property(char *buf, size_t bufsize)
 {
-       struct device_node *np;
+       struct device_node *np __free(device_node) = NULL;
        char *tmp;
        buf = parse_node(buf, bufsize, &np);
 
@@ -315,7 +315,7 @@ static int do_remove_property(char *buf, size_t bufsize)
 
 static int do_update_property(char *buf, size_t bufsize)
 {
-       struct device_node *np;
+       struct device_node *np __free(device_node) = NULL;
        unsigned char *value;
        char *name, *end, *next_prop;
        int length;

-- 
2.53.0

Reply via email to