Skip to contentSkip to conversation

fix skb leak in isdn_common.c

PATCH In review Darren Jenkins\ 2 participants 2 messages Sep 7, 2006 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix skb leak in isdn_common.c

G'day list,

Coverity CID 1356,

There looks to be a small leak in isdn_writebuf_stub() in isdn_common.c, when copy_from_user() returns an un-copied data length (length != 0). The below patch should be a minimally invasive fix.

compile tested on allyesconfig

Fix skb leak in isdn_common.c

isdn/i4l/isdn_common.c renamed from isdn/i4l/isdn_common.c.orig +3 -1
@@ -1967,8 +1967,10 @@ isdn_writebuf_stub(int drvidx, int chan,
 	if (!skb)
 		return -ENOMEM;
 	skb_reserve(skb, hl);
-	if (copy_from_user(skb_put(skb, len), buf, len))
+	if (copy_from_user(skb_put(skb, len), buf, len)) {
+		dev_kfree_skb(skb);
 		return -EFAULT;
+	}
 	ret = dev->drv[drvidx]->interface->writebuf_skb(drvidx, chan, 1, skb);
 	if (ret <= 0)
 		dev_kfree_skb(skb);

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Darren Jenkins

G'day list,

Coverity CID 1356,

There looks to be a small leak in isdn_writebuf_stub() in isdn_common.c, when copy_from_user() returns an un-copied data length (length != 0). The below patch should be a minimally invasive fix.

compile tested on allyesconfig

Yes this is obvious correct.

Quoted 19 lines

Fix skb leak in isdn_common.c

isdn/i4l/isdn_common.c renamed from isdn/i4l/isdn_common.c.orig +3 -1
@@ -1967,8 +1967,10 @@ isdn_writebuf_stub(int drvidx, int chan,
 	if (!skb)
 		return -ENOMEM;
 	skb_reserve(skb, hl);
-	if (copy_from_user(skb_put(skb, len), buf, len))
+	if (copy_from_user(skb_put(skb, len), buf, len)) {
+		dev_kfree_skb(skb);
 		return -EFAULT;
+	}
 	ret = dev->drv[drvidx]->interface->writebuf_skb(drvidx, chan, 1, skb);
 	if (ret <= 0)
 		dev_kfree_skb(skb);
Signature · 7 lines
Karsten Keil
SuSE Labs
ISDN development
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors