Skip to contentSkip to conversation

Free the memory allocated by memdup_user() in fs/sysfs/bin.c

PATCH In review Catalin Marinas 2 participants 2 messages Jul 8, 2009 – Jul 12, 2009 Driver core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Free the memory allocated by memdup_user() in fs/sysfs/bin.c

Commit 1c8542c7bb replaced kmalloc() with memdup_user() in the write() function but also dropped the kfree(temp). The memdup_user() function allocates memory which is never freed.

---
 fs/sysfs/bin.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
fs/sysfs/bin.c +1 -0
index 9345806..2524714 100644
@@ -171,6 +171,7 @@ static ssize_t write(struct file *file, const char __user *userbuf,
 	if (count > 0)
 		*off = offs + count;
 
+	kfree(temp);
 	return count;
 }
 
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Catalin Marinas

Commit 1c8542c7bb replaced kmalloc() with memdup_user() in the write() function but also dropped the kfree(temp). The memdup_user() function allocates memory which is never freed.

Quoted 24 lines
---
 fs/sysfs/bin.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
fs/sysfs/bin.c +1 -1
index 9345806..2524714 100644
@@ -171,6 +171,7 @@ static ssize_t write(struct file *file, const char __user *userbuf,
 	if (count > 0)
 		*off = offs + count;
 
+	kfree(temp);
 	return count;
 }
 
 
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/