Skip to content

Commit

Permalink
powerpc/secvar: fix refcount leak in format_show()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Hangyu Hua authored and Michael Ellerman committed Mar 8, 2022
1 parent 1a76e52 commit d601fd2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions arch/powerpc/kernel/secvar-sysfs.c
Original file line number Diff line number Diff line change
@@ -26,15 +26,18 @@ static ssize_t format_show(struct kobject *kobj, struct kobj_attribute *attr,
const char *format;

node = of_find_compatible_node(NULL, NULL, "ibm,secvar-backend");
if (!of_device_is_available(node))
return -ENODEV;
if (!of_device_is_available(node)) {
rc = -ENODEV;
goto out;
}

rc = of_property_read_string(node, "format", &format);
if (rc)
return rc;
goto out;

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

out:
of_node_put(node);

return rc;

0 comments on commit d601fd2

Please sign in to comment.