mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-21 23:16:50 +08:00
net: ncsi: fix skb leak in error paths
Early return paths in NCSI RX and AEN handlers fail to release the received skb, resulting in a memory leak. Specifically, ncsi_aen_handler() returns on invalid AEN packets without consuming the skb. Similarly, ncsi_rcv_rsp() exits early when failing to resolve the NCSI device, response handler, or request, leaving the skb unfreed. CC: stable@vger.kernel.org Fixes:7a82ecf4cf("net/ncsi: NCSI AEN packet handler") Fixes:138635cc27("net/ncsi: NCSI response packet handler") Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com> Link: https://patch.msgid.link/20260305060656.3357250-1-zhangjian.3032@bytedance.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
63f428cb94
commit
5c3398a542
@@ -224,7 +224,8 @@ int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb)
|
||||
if (!nah) {
|
||||
netdev_warn(ndp->ndev.dev, "Invalid AEN (0x%x) received\n",
|
||||
h->type);
|
||||
return -ENOENT;
|
||||
ret = -ENOENT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = ncsi_validate_aen_pkt(h, nah->payload);
|
||||
|
||||
@@ -1176,8 +1176,10 @@ int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev,
|
||||
/* Find the NCSI device */
|
||||
nd = ncsi_find_dev(orig_dev);
|
||||
ndp = nd ? TO_NCSI_DEV_PRIV(nd) : NULL;
|
||||
if (!ndp)
|
||||
return -ENODEV;
|
||||
if (!ndp) {
|
||||
ret = -ENODEV;
|
||||
goto err_free_skb;
|
||||
}
|
||||
|
||||
/* Check if it is AEN packet */
|
||||
hdr = (struct ncsi_pkt_hdr *)skb_network_header(skb);
|
||||
@@ -1199,7 +1201,8 @@ int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev,
|
||||
if (!nrh) {
|
||||
netdev_err(nd->dev, "Received unrecognized packet (0x%x)\n",
|
||||
hdr->type);
|
||||
return -ENOENT;
|
||||
ret = -ENOENT;
|
||||
goto err_free_skb;
|
||||
}
|
||||
|
||||
/* Associate with the request */
|
||||
@@ -1207,7 +1210,8 @@ int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev,
|
||||
nr = &ndp->requests[hdr->id];
|
||||
if (!nr->used) {
|
||||
spin_unlock_irqrestore(&ndp->lock, flags);
|
||||
return -ENODEV;
|
||||
ret = -ENODEV;
|
||||
goto err_free_skb;
|
||||
}
|
||||
|
||||
nr->rsp = skb;
|
||||
@@ -1261,4 +1265,8 @@ out_netlink:
|
||||
out:
|
||||
ncsi_free_request(nr);
|
||||
return ret;
|
||||
|
||||
err_free_skb:
|
||||
kfree_skb(skb);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user