Skip to content

Commit b9cabe5

Browse files
jjuhlDavid S. Miller
authored andcommitted
ieee802154: Don't leak memory in ieee802154_nl_fill_phy
In net/ieee802154/nl-phy.c::ieee802154_nl_fill_phy() I see two small issues. 1) If the allocation of 'buf' fails we may just as well return -EMSGSIZE directly rather than jumping to 'out:' and do a pointless kfree(0). 2) We do not free 'buf' unless we jump to one of the error labels and this leaks memory. This patch should address both. Signed-off-by: Jesper Juhl <jj@chaosbits.net> Acked-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> Signed-off-by: David S. Miller <davem@conan.davemloft.net>
1 parent 84860c7 commit b9cabe5

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎net/ieee802154/nl-phy.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 pid,
4444
pr_debug("%s\n", __func__);
4545

4646
if (!buf)
47-
goto out;
47+
return -EMSGSIZE;
4848

4949
hdr = genlmsg_put(msg, 0, seq, &nl802154_family, flags,
5050
IEEE802154_LIST_PHY);
@@ -65,6 +65,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 pid,
6565
pages * sizeof(uint32_t), buf);
6666

6767
mutex_unlock(&phy->pib_lock);
68+
kfree(buf);
6869
return genlmsg_end(msg, hdr);
6970

7071
nla_put_failure:

0 commit comments

Comments
 (0)