* [PATCH net] fm10k: fix potential memleak in fm10k_xmit_frame()
@ 2022-11-18 12:37 Zhang Changzhong
2022-11-18 15:36 ` Alexander H Duyck
0 siblings, 1 reply; 2+ messages in thread
From: Zhang Changzhong @ 2022-11-18 12:37 UTC (permalink / raw)
To: Jesse Brandeburg, Tony Nguyen, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Jeff Kirsher, Alexander Duyck
Cc: Zhang Changzhong, netdev, linux-kernel
The fm10k_xmit_frame() returns NETDEV_TX_OK without freeing skb in error
handling case, add dev_kfree_skb() to fix it. Compile tested only.
Fixes: b101c9626477 ("fm10k: Add transmit and receive fastpath and interrupt handlers")
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
---
drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
index 2cca9e8..c7b672a 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
@@ -531,8 +531,10 @@ static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
/* make sure there is enough room to move the ethernet header */
- if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN)))
+ if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN))) {
+ dev_kfree_skb(skb);
return NETDEV_TX_OK;
+ }
/* verify the skb head is not shared */
err = skb_cow_head(skb, 0);
--
2.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] fm10k: fix potential memleak in fm10k_xmit_frame()
2022-11-18 12:37 [PATCH net] fm10k: fix potential memleak in fm10k_xmit_frame() Zhang Changzhong
@ 2022-11-18 15:36 ` Alexander H Duyck
0 siblings, 0 replies; 2+ messages in thread
From: Alexander H Duyck @ 2022-11-18 15:36 UTC (permalink / raw)
To: Zhang Changzhong, Jesse Brandeburg, Tony Nguyen, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Jeff Kirsher,
Alexander Duyck
Cc: netdev, linux-kernel
On Fri, 2022-11-18 at 20:37 +0800, Zhang Changzhong wrote:
> The fm10k_xmit_frame() returns NETDEV_TX_OK without freeing skb in error
> handling case, add dev_kfree_skb() to fix it. Compile tested only.
>
> Fixes: b101c9626477 ("fm10k: Add transmit and receive fastpath and interrupt handlers")
> Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
> ---
> drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
> index 2cca9e8..c7b672a 100644
> --- a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
> +++ b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c
> @@ -531,8 +531,10 @@ static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev)
> return NETDEV_TX_OK;
>
> /* make sure there is enough room to move the ethernet header */
> - if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN)))
> + if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN))) {
> + dev_kfree_skb(skb);
> return NETDEV_TX_OK;
> + }
>
> /* verify the skb head is not shared */
> err = skb_cow_head(skb, 0);
Fix looks good to me.
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-18 15:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-18 12:37 [PATCH net] fm10k: fix potential memleak in fm10k_xmit_frame() Zhang Changzhong
2022-11-18 15:36 ` Alexander H Duyck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox