staging: ks7010: avoid dereferencing packet if it is null
authorColin Ian King <colin.king@canonical.com>
Wed, 7 Sep 2016 16:23:09 +0000 (17:23 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 12 Sep 2016 09:18:15 +0000 (11:18 +0200)
Updating tx_bytes from packet->len if packet is null will cause
a null pointer dereference, so only update tx_bytes if it packet
is not null.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ks7010/ks_wlan_net.c

index 1e21eb1c46675721c19e4f4a6a06cf64fc393458..d69b4c945d218621f71fa25fe63fb38fe123e915 100644 (file)
@@ -3396,13 +3396,13 @@ void send_packet_complete(void *arg1, void *arg2)
 
        DPRINTK(3, "\n");
 
-       priv->nstats.tx_bytes += packet->len;
        priv->nstats.tx_packets++;
 
        if (netif_queue_stopped(priv->net_dev))
                netif_wake_queue(priv->net_dev);
 
        if (packet) {
+               priv->nstats.tx_bytes += packet->len;
                dev_kfree_skb(packet);
                packet = NULL;
        }