Skip to contentSkip to conversation

Memleak in ircomm_core

PATCH Oleg Drokin 2 participants 2 messages Mar 9, 2003 Networking

lore
Share & tools
lore
#0 lore raw

Hello!

There seems to be a memleak on error exit path. The same patch should apply to 2.5 and 2.4

Found with help of smatch + enhanced unfree script.

Bye,
Oleg

===== net/irda/ircomm/ircomm_core.c 1.5 vs edited =====

net/irda/ircomm/ircomm_core.c +3 -1
@@ -121,8 +121,10 @@
 	} else
 		ret = ircomm_open_tsap(self);
 
-	if (ret < 0)
+	if (ret < 0) {
+		kfree(self);
 		return NULL;
+	}
 
 	self->service_type = service_type;
 	self->line = line;
#1 lore raw
Quoted 16 lines · Oleg Drokin

Hello!

There seems to be a memleak on error exit path. The same patch should apply to 2.5 and 2.4

Found with help of smatch + enhanced unfree script.

Bye,
Oleg

===== net/irda/ircomm/ircomm_core.c 1.5 vs edited =====

net/irda/ircomm/ircomm_core.c +0 -0
@@ -121,8 +121,10 @@
 	} else
 		ret = ircomm_open_tsap(self);

net/irda/ircomm/ircomm_core.c

Quoted 10 lines
net/irda/ircomm/ircomm_core.c +3 -2
 
-	if (ret < 0)
+	if (ret < 0) {
+		kfree(self);
 		return NULL;
+	}
 
 	self->service_type = service_type;
 	self->line = line;
-

Must be an old one - looks like the same patch is needed in 2.2.24-rc5.

HTH,
Neale.