Skip to content

Commit 9dc373f

Browse files
Yunlongsgregkh
authored andcommitted
net:emac/emac-mac: Fix a use after free in emac_mac_tx_buf_send
[ Upstream commit 6d72e7c ] In emac_mac_tx_buf_send, it calls emac_tx_fill_tpd(..,skb,..). If some error happens in emac_tx_fill_tpd(), the skb will be freed via dev_kfree_skb(skb) in error branch of emac_tx_fill_tpd(). But the freed skb is still used via skb->len by netdev_sent_queue(,skb->len). As i observed that emac_tx_fill_tpd() haven't modified the value of skb->len, thus my patch assigns skb->len to 'len' before the possible free and use 'len' instead of skb->len later. Fixes: b9b17de ("net: emac: emac gigabit ethernet controller driver") Signed-off-by: Lv Yunlong <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 8fcdfa7 commit 9dc373f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/net/ethernet/qualcomm/emac/emac-mac.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,7 @@ netdev_tx_t emac_mac_tx_buf_send(struct emac_adapter *adpt,
14371437
{
14381438
struct emac_tpd tpd;
14391439
u32 prod_idx;
1440+
int len;
14401441

14411442
memset(&tpd, 0, sizeof(tpd));
14421443

@@ -1456,9 +1457,10 @@ netdev_tx_t emac_mac_tx_buf_send(struct emac_adapter *adpt,
14561457
if (skb_network_offset(skb) != ETH_HLEN)
14571458
TPD_TYP_SET(&tpd, 1);
14581459

1460+
len = skb->len;
14591461
emac_tx_fill_tpd(adpt, tx_q, skb, &tpd);
14601462

1461-
netdev_sent_queue(adpt->netdev, skb->len);
1463+
netdev_sent_queue(adpt->netdev, len);
14621464

14631465
/* Make sure the are enough free descriptors to hold one
14641466
* maximum-sized SKB. We need one desc for each fragment,

0 commit comments

Comments
 (0)