Skip to contentSkip to conversation

memleak in 802.1q vlan proc code

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

lore
Share & tools
lore
#0 lore raw

Hello!

There is a memleak on error exit path, identical in 2.4 and 2.5. Same patch should apply to 2.4 and 2.5.

Found with help of smatch + enhanced unfree script.

Bye,
Oleg
===== net/8021q/vlanproc.c 1.6 vs edited =====

net/8021q/vlanproc.c +3 -1
@@ -252,8 +252,10 @@
 	offs = file->f_pos;
 	if (offs < pos) {
 		len = min_t(int, pos - offs, count);
-		if (copy_to_user(buf, (page + offs), len))
+		if (copy_to_user(buf, (page + offs), len)) {
+			kfree(page);
 			return -EFAULT;
+		}
 
 		file->f_pos += len;
 	} else {