diff mbox series

[wireless] brcmfmac: fix potential memory leak in brcmf_netdev_start_xmit()

Message ID 1668657281-28480-1-git-send-email-zhangchangzhong@huawei.com
State Superseded
Headers show
Series [wireless] brcmfmac: fix potential memory leak in brcmf_netdev_start_xmit() | expand

Commit Message

Zhang Changzhong Nov. 17, 2022, 3:54 a.m. UTC
The brcmf_netdev_start_xmit() returns NETDEV_TX_OK without freeing skb
in case of pskb_expand_head() fails, add dev_kfree_skb() to fix it.

Fixes: 270a6c1f65fe ("brcmfmac: rework headroom check in .start_xmit()")
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Kalle Valo Nov. 17, 2022, 10:09 a.m. UTC | #1
Zhang Changzhong <zhangchangzhong@huawei.com> writes:

> The brcmf_netdev_start_xmit() returns NETDEV_TX_OK without freeing skb
> in case of pskb_expand_head() fails, add dev_kfree_skb() to fix it.
>
> Fixes: 270a6c1f65fe ("brcmfmac: rework headroom check in .start_xmit()")
> Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>

I assume you have not tested this on a real device? Then it would be
really important to add "Compile tested only" to the commit log so that
we know it's untested.
Zhang Changzhong Nov. 17, 2022, 11:04 a.m. UTC | #2
On 2022/11/17 18:09, Kalle Valo wrote:
> Zhang Changzhong <zhangchangzhong@huawei.com> writes:
> 
>> The brcmf_netdev_start_xmit() returns NETDEV_TX_OK without freeing skb
>> in case of pskb_expand_head() fails, add dev_kfree_skb() to fix it.
>>
>> Fixes: 270a6c1f65fe ("brcmfmac: rework headroom check in .start_xmit()")
>> Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
> 
> I assume you have not tested this on a real device? Then it would be
> really important to add "Compile tested only" to the commit log so that
> we know it's untested.
> 

OK, I'll add "Compile tested only" to the next version and other untested
patches.

Thanks,
Changzhong
Kalle Valo Nov. 18, 2022, 6:43 p.m. UTC | #3
Zhang Changzhong <zhangchangzhong@huawei.com> writes:

> On 2022/11/17 18:09, Kalle Valo wrote:
>> Zhang Changzhong <zhangchangzhong@huawei.com> writes:
>> 
>>> The brcmf_netdev_start_xmit() returns NETDEV_TX_OK without freeing skb
>>> in case of pskb_expand_head() fails, add dev_kfree_skb() to fix it.
>>>
>>> Fixes: 270a6c1f65fe ("brcmfmac: rework headroom check in .start_xmit()")
>>> Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
>> 
>> I assume you have not tested this on a real device? Then it would be
>> really important to add "Compile tested only" to the commit log so that
>> we know it's untested.
>> 
>
> OK, I'll add "Compile tested only" to the next version and other untested
> patches.

Thanks. I wish it would become common to use that "Compile tested only".
diff mbox series

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 595ae3a..175272c 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -335,6 +335,7 @@  static netdev_tx_t brcmf_netdev_start_xmit(struct sk_buff *skb,
 			bphy_err(drvr, "%s: failed to expand headroom\n",
 				 brcmf_ifname(ifp));
 			atomic_inc(&drvr->bus_if->stats.pktcow_failed);
+			dev_kfree_skb(skb);
 			goto done;
 		}
 	}