[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220228091103.39749-1-hbh25y@gmail.com>
Date: Mon, 28 Feb 2022 17:11:03 +0800
From: Hangyu Hua <hbh25y@...il.com>
To: mpe@...erman.id.au, benh@...nel.crashing.org, paulus@...ba.org
Cc: linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
Hangyu Hua <hbh25y@...il.com>
Subject: [PATCH] powerpc: kernel: fix a refcount leak in format_show()
node needs to be dropped when of_property_read_string fails. So an earlier call
to of_node_put is required here.
Signed-off-by: Hangyu Hua <hbh25y@...il.com>
---
arch/powerpc/kernel/secvar-sysfs.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/powerpc/kernel/secvar-sysfs.c b/arch/powerpc/kernel/secvar-sysfs.c
index a0a78aba2083..cd0fa7028d86 100644
--- a/arch/powerpc/kernel/secvar-sysfs.c
+++ b/arch/powerpc/kernel/secvar-sysfs.c
@@ -30,13 +30,12 @@ static ssize_t format_show(struct kobject *kobj, struct kobj_attribute *attr,
return -ENODEV;
rc = of_property_read_string(node, "format", &format);
+ of_node_put(node);
if (rc)
return rc;
rc = sprintf(buf, "%s\n", format);
- of_node_put(node);
-
return rc;
}
--
2.25.1
Powered by blists - more mailing lists