linux/drivers/isdn
Jesper Juhl 2393c944d5 ISDN, Gigaset: Fix memory leak in do_disconnect_req()
Hi,

In drivers/isdn/gigaset/capi.c::do_disconnect_req() we will leak the
memory allocated (with kmalloc) to 'b3cmsg' if the call to alloc_skb()
fails.

...
		b3cmsg = kmalloc(sizeof(*b3cmsg), GFP_KERNEL);
	allocation here ------^
		if (!b3cmsg) {
			dev_err(cs->dev, "%s: out of memory\n", __func__);
			send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR);
			return;
		}
		capi_cmsg_header(b3cmsg, ap->id, CAPI_DISCONNECT_B3, CAPI_IND,
				 ap->nextMessageNumber++,
				 cmsg->adr.adrPLCI | (1 << 16));
		b3cmsg->Reason_B3 = CapiProtocolErrorLayer1;
		b3skb = alloc_skb(CAPI_DISCONNECT_B3_IND_BASELEN, GFP_KERNEL);
		if (b3skb == NULL) {
			dev_err(cs->dev, "%s: out of memory\n", __func__);
			send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR);
			return;
	leak here ------^
...

This leak is easily fixed by just kfree()'ing the memory allocated to
'b3cmsg' right before we return. The following patch does that.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-12-31 11:17:10 -08:00
..
act2000 isdn: Free irq_data namespace 2010-10-04 11:00:55 +02:00
capi convert get_sb_single() users 2010-10-29 04:16:28 -04:00
divert isdn: potential buffer overflows 2010-09-06 18:29:18 -07:00
gigaset ISDN, Gigaset: Fix memory leak in do_disconnect_req() 2010-12-31 11:17:10 -08:00
hardware drivers/isdn: delete double assignment 2010-10-27 12:23:21 -07:00
hisax trivial: fix typos concerning "function" 2010-11-01 06:38:12 -07:00
hysdn drivers: isdn: remove custom strtoul() 2010-07-15 19:05:25 -07:00
i4l Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2010-10-24 13:41:39 -07:00
icn isdn: icn: Fix stack corruption bug. 2010-11-24 11:19:05 -08:00
isdnloop include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
mISDN isdn: mISDN: socket: fix information leak to userland 2010-10-30 16:49:38 -07:00
pcbit drivers/isdn: Use static const char * const where possible 2010-09-14 20:22:02 -07:00
sc isdn: strcpy() => strlcpy() 2010-10-08 10:21:22 -07:00
Kconfig
Makefile