sparc: Fix possible memleak in of_set_property
PATCH 1/1 sparc: Fix possible memleak in of_set_property
If we do not find the target property, this part of memory that allocated to new_val is not referenced by anyone. It can not be freed after of_set_property() returns, then it will be leaked. We fix the problem by freeing it when not found the target name of the property.
Fixes dfa76060be85 ("sparc: Create common area for OF device layer code.")
Signed-off-by Zhang Qilong <[email protected]>
--- arch/sparc/kernel/prom_common.c | 3 +++ 1 file changed, 3 insertions(+)
arch/sparc/kernel/prom_common.c +3 -0
@@ -91,6 +91,9 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int lenraw_spin_unlock_irqrestore (&devtree_lock, flags);mutex_unlock (&of_set_property_mutex); +if (err) +kfree (new_val); +/* XXX Upate procfs if necessary... */ return err;
Signature · 1 line
2.25.1