diff options
author | Jesper Juhl <jj@chaosbits.net> | 2010-12-26 04:59:58 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-12-31 14:17:10 -0500 |
commit | 2393c944d5d60eedaede80273ede8a816b5fa3e0 (patch) | |
tree | ec828bc121f178194167396aaab5a79852cae695 /drivers/isdn/gigaset | |
parent | 9f260e0efa4766e56d0ac14f1aeea6ee5eb8fe83 (diff) |
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>
Diffstat (limited to 'drivers/isdn/gigaset')
-rw-r--r-- | drivers/isdn/gigaset/capi.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c index bcc174e4f3b1..658e75f18d05 100644 --- a/drivers/isdn/gigaset/capi.c +++ b/drivers/isdn/gigaset/capi.c | |||
@@ -1900,6 +1900,7 @@ static void do_disconnect_req(struct gigaset_capi_ctr *iif, | |||
1900 | if (b3skb == NULL) { | 1900 | if (b3skb == NULL) { |
1901 | dev_err(cs->dev, "%s: out of memory\n", __func__); | 1901 | dev_err(cs->dev, "%s: out of memory\n", __func__); |
1902 | send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR); | 1902 | send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR); |
1903 | kfree(b3cmsg); | ||
1903 | return; | 1904 | return; |
1904 | } | 1905 | } |
1905 | capi_cmsg2message(b3cmsg, | 1906 | capi_cmsg2message(b3cmsg, |