mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
be2net: fix potential memory leak in be_xmit()
[ Upstream commit e4dd8bfe0f6a23acd305f9b892c00899089bd621 ]
The be_xmit() returns NETDEV_TX_OK without freeing skb
in case of be_xmit_enqueue() fails, add dev_kfree_skb_any() to fix it.
Fixes: 760c295e0e ("be2net: Support for OS2BMC.")
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Message-ID: <20241015144802.12150-1-wanghai38@huawei.com>
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
1a17a4ac2d
commit
4c5f170ef4
@@ -1382,10 +1382,8 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
|
|||||||
be_get_wrb_params_from_skb(adapter, skb, &wrb_params);
|
be_get_wrb_params_from_skb(adapter, skb, &wrb_params);
|
||||||
|
|
||||||
wrb_cnt = be_xmit_enqueue(adapter, txo, skb, &wrb_params);
|
wrb_cnt = be_xmit_enqueue(adapter, txo, skb, &wrb_params);
|
||||||
if (unlikely(!wrb_cnt)) {
|
if (unlikely(!wrb_cnt))
|
||||||
dev_kfree_skb_any(skb);
|
goto drop_skb;
|
||||||
goto drop;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if os2bmc is enabled and if the pkt is destined to bmc,
|
/* if os2bmc is enabled and if the pkt is destined to bmc,
|
||||||
* enqueue the pkt a 2nd time with mgmt bit set.
|
* enqueue the pkt a 2nd time with mgmt bit set.
|
||||||
@@ -1394,7 +1392,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
|
|||||||
BE_WRB_F_SET(wrb_params.features, OS2BMC, 1);
|
BE_WRB_F_SET(wrb_params.features, OS2BMC, 1);
|
||||||
wrb_cnt = be_xmit_enqueue(adapter, txo, skb, &wrb_params);
|
wrb_cnt = be_xmit_enqueue(adapter, txo, skb, &wrb_params);
|
||||||
if (unlikely(!wrb_cnt))
|
if (unlikely(!wrb_cnt))
|
||||||
goto drop;
|
goto drop_skb;
|
||||||
else
|
else
|
||||||
skb_get(skb);
|
skb_get(skb);
|
||||||
}
|
}
|
||||||
@@ -1408,6 +1406,8 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev)
|
|||||||
be_xmit_flush(adapter, txo);
|
be_xmit_flush(adapter, txo);
|
||||||
|
|
||||||
return NETDEV_TX_OK;
|
return NETDEV_TX_OK;
|
||||||
|
drop_skb:
|
||||||
|
dev_kfree_skb_any(skb);
|
||||||
drop:
|
drop:
|
||||||
tx_stats(txo)->tx_drv_drops++;
|
tx_stats(txo)->tx_drv_drops++;
|
||||||
/* Flush the already enqueued tx requests */
|
/* Flush the already enqueued tx requests */
|
||||||
|
|||||||
Reference in New Issue
Block a user