WSL2-Linux-Kernel/drivers/isdn/gigaset
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
..
Kconfig isdn/gigaset: remove EXPERIMENTAL tag from GIGASET_CAPI 2010-07-07 16:57:56 -07:00
Makefile gigaset: add Kernel CAPI interface (v3) 2009-10-06 22:43:53 -07:00
asyncdata.c isdn/gigaset: honor CAPI application's buffer size request 2010-06-25 21:16:59 -07:00
bas-gigaset.c isdn/gigaset: improve bas_gigaset USB error reporting 2010-10-01 00:33:37 -07:00
capi.c ISDN, Gigaset: Fix memory leak in do_disconnect_req() 2010-12-31 11:17:10 -08:00
common.c isdn/gigaset: drop obsolete debug option 2010-10-01 00:33:34 -07:00
dummyll.c gigaset: fix build failure 2010-03-17 14:22:07 -07:00
ev-layer.c drivers: isdn: get rid of custom strtoul() 2010-07-15 19:05:25 -07:00
gigaset.h isdn/gigaset: drop obsolete debug option 2010-10-01 00:33:34 -07:00
i4l.c isdn/gigaset: drop obsolete debug option 2010-10-01 00:33:34 -07:00
interface.c isdn/gigaset: remove obsolete compile time options 2010-07-07 16:57:54 -07:00
isocdata.c isdn/gigaset: correct bas_gigaset rx buffer handling 2010-10-01 00:33:33 -07:00
proc.c gigaset: include cleanup cleanup 2010-04-18 02:33:29 -07:00
ser-gigaset.c isdn/gigaset: avoid copying AT commands twice 2010-07-07 16:57:51 -07:00
usb-gigaset.c isdn/gigaset: avoid copying AT commands twice 2010-07-07 16:57:51 -07:00