Skip to contentSkip to conversation

Don't leak 'listeners' in netlink_kernel_create()

DISCUSSION Applied Eric W. Biederman 2 participants 2 messages Oct 14, 2007 – Oct 15, 2007 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Eric W. Biederman

author Acked-by
#1 lore raw
In reply to a message not in the archive
Quoted 8 lines · Jesper Juhl

From: Jesper Juhl <[email protected]>
Subject: Don't leak 'listeners' in netlink_kernel_create()

The Coverity checker spotted that we'll leak the storage allocated to 'listeners' in netlink_kernel_create() when the
if (!nl_table[unit].registered)
check is false.

Quoted 4 lines

This patch avoids the leak.

This patch appears trivially correct to me.

Quoted 16 lines

---

 af_netlink.c |    2 ++
 1 file changed, 2 insertions(+)
net/netlink/af_netlink.c renamed from net/netlink/af_netlink.c~ +2 -0
@@ -1378,6 +1378,8 @@ netlink_kernel_create(struct net *net, i
 		nl_table[unit].cb_mutex = cb_mutex;
 		nl_table[unit].module = module;
 		nl_table[unit].registered = 1;
+	} else {
+		kfree(listeners);
 	}
 	netlink_table_ungrab();
 
maintainer Applied
#2 lore raw

From: [email protected] (Eric W. Biederman)
Date: Sun, 14 Oct 2007 16:30:06 -0600

Quoted 10 lines
Quoted 8 lines · Jesper Juhl

From: Jesper Juhl <[email protected]>
Subject: Don't leak 'listeners' in netlink_kernel_create()

The Coverity checker spotted that we'll leak the storage allocated to 'listeners' in netlink_kernel_create() when the
if (!nl_table[unit].registered)
check is false.

Quoted 7 lines
Quoted 4 lines

This patch avoids the leak.

This patch appears trivially correct to me.

Applied, thanks everyone.