[PATCH] sparc: Fix possible memleak in of_set_property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <zhangqilong3@xxxxxxxxxx>
---
 arch/sparc/kernel/prom_common.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
index c9ec70888a39..c127a815db5e 100644
--- a/arch/sparc/kernel/prom_common.c
+++ b/arch/sparc/kernel/prom_common.c
@@ -91,6 +91,9 @@ int of_set_property(struct device_node *dp, const char *name, void *val, int len
 	raw_spin_unlock_irqrestore(&devtree_lock, flags);
 	mutex_unlock(&of_set_property_mutex);
 
+	if (err)
+		kfree(new_val);
+
 	/* XXX Upate procfs if necessary... */
 
 	return err;
-- 
2.25.1




[Index of Archives]     [Kernel Development]     [DCCP]     [Linux ARM Development]     [Linux]     [Photo]     [Yosemite Help]     [Linux ARM Kernel]     [Linux SCSI]     [Linux x86_64]     [Linux Hams]

  Powered by Linux