diff options
author | Pan Bian <bianpan2016@163.com> | 2019-11-05 22:49:11 +0800 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2020-02-11 20:03:26 +0000 |
commit | ded55327ebba737a602eb1fe2f653ce41f5156da (patch) | |
tree | ab67f08551c6df5b22d13c7a7f33ec04ccdb2c94 /drivers/staging | |
parent | c4064ba1266852c00418c40fd4c2930b8c17058e (diff) | |
download | linux-stable-ded55327ebba737a602eb1fe2f653ce41f5156da.tar.gz linux-stable-ded55327ebba737a602eb1fe2f653ce41f5156da.tar.bz2 linux-stable-ded55327ebba737a602eb1fe2f653ce41f5156da.zip |
staging: rtl8192e: fix potential use after free
commit b7aa39a2ed0112d07fc277ebd24a08a7b2368ab9 upstream.
The variable skb is released via kfree_skb() when the return value of
_rtl92e_tx is not zero. However, after that, skb is accessed again to
read its length, which may result in a use after free bug. This patch
fixes the bug by moving the release operation to where skb is never
used later.
Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/1572965351-6745-1-git-send-email-bianpan2016@163.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index 2920e406030a..0fac550b6dbd 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -1884,8 +1884,6 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); skb_push(skb, priv->rtllib->tx_headroom); ret = rtl8192_tx(dev, skb); - if (ret != 0) - kfree_skb(skb); if (queue_index != MGNT_QUEUE) { priv->rtllib->stats.tx_bytes += (skb->len - @@ -1893,6 +1891,9 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, priv->rtllib->stats.tx_packets++; } + if (ret != 0) + kfree_skb(skb); + return; } |