libertas: Fix a double free in if_spi_c2h_data()
authorDan Williams <dcbw@redhat.com>
Wed, 24 Jul 2019 14:38:15 +0000 (09:38 -0500)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 6 Aug 2019 12:35:59 +0000 (15:35 +0300)
The lbs_process_rxed_packet() frees the skb.  It didn't originally, but
we fixed it in commit f54930f36311 ("libertas: don't leak skb on receive
error").

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/marvell/libertas/if_spi.c

index 27067e7..d07fe82 100644 (file)
@@ -766,19 +766,15 @@ static int if_spi_c2h_data(struct if_spi_card *card)
 
        /* Read the data from the WLAN module into our skb... */
        err = spu_read(card, IF_SPI_DATA_RDWRPORT_REG, data, ALIGN(len, 4));
-       if (err)
-               goto free_skb;
+       if (err) {
+               dev_kfree_skb(skb);
+               goto out;
+       }
 
        /* pass the SKB to libertas */
        err = lbs_process_rxed_packet(card->priv, skb);
-       if (err)
-               goto free_skb;
-
-       /* success */
-       goto out;
+       /* lbs_process_rxed_packet() consumes the skb */
 
-free_skb:
-       dev_kfree_skb(skb);
 out:
        if (err)
                netdev_err(priv->dev, "%s: err=%d\n", __func__, err);