Skip to content

Commit d601fd2

Browse files
HBh25Ympe
authored andcommitted
powerpc/secvar: fix refcount leak in format_show()
Refcount leak will happen when format_show returns failure in multiple cases. Unified management of of_node_put can fix this problem. Signed-off-by: Hangyu Hua <hbh25y@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20220302021959.10959-1-hbh25y@gmail.com
1 parent 1a76e52 commit d601fd2

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

arch/powerpc/kernel/secvar-sysfs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@ static ssize_t format_show(struct kobject *kobj, struct kobj_attribute *attr,
2626
const char *format;
2727

2828
node = of_find_compatible_node(NULL, NULL, "ibm,secvar-backend");
29-
if (!of_device_is_available(node))
30-
return -ENODEV;
29+
if (!of_device_is_available(node)) {
30+
rc = -ENODEV;
31+
goto out;
32+
}
3133

3234
rc = of_property_read_string(node, "format", &format);
3335
if (rc)
34-
return rc;
36+
goto out;
3537

3638
rc = sprintf(buf, "%s\n", format);
3739

40+
out:
3841
of_node_put(node);
3942

4043
return rc;

0 commit comments

Comments
 (0)