Skip to contentSkip to conversation

lib: fix a memory leak risk

PATCH In review Wan ZongShun 2 participants 2 messages Jun 4, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: fix a memory leak risk

The netlink_kernel_create failed will arouse memory leak, this patch is to add the 'kfree(ue_sk)' here.

---
 lib/kobject_uevent.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
lib/kobject_uevent.c +1 -0
index 59c1551..08e15f7 100644
@@ -378,6 +378,7 @@ static int uevent_net_init(struct net *net)
 	if (!ue_sk->sk) {
 		printk(KERN_ERR
 		       "kobject_uevent: unable to create netlink socket!\n");
+		kfree(ue_sk);
 		return -ENODEV;
 	}
 	mutex_lock(&uevent_sock_mutex);
Signature · 1 line
1.6.3.3
#1 lore raw
Quoted 14 lines · Wan ZongShun

The netlink_kernel_create failed will arouse memory leak, this patch is to add the 'kfree(ue_sk)' here.

---
 lib/kobject_uevent.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
lib/kobject_uevent.c +0 -0
index 59c1551..08e15f7 100644

lib/kobject_uevent.c static int uevent_net_init(struct net *net) · line 381

Quoted 4 lines
lib/kobject_uevent.c +1 -0
@@ -378,6 +378,7 @@ static int uevent_net_init(struct net *net)
 	if (!ue_sk->sk) {
 		printk(KERN_ERR
 		       "kobject_uevent: unable to create netlink socket!\n");
+		kfree(ue_sk);

Sorry, others already sent this patch in before you, it's already in the linux-next tree, and is going to Linus later today.

thanks,

greg k-h