linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dcbw@redhat.com>
To: Kalle Valo <kvalo@codeaurora.org>
Cc: Philip Rakity <prakity@yahoo.com>,
	libertas-dev@lists.infradead.org,
	kernel-janitors@vger.kernel.org, linux-wireless@vger.kernel.org,
	Lubomir Rintel <lkundrak@v3.sk>,
	Allison Randal <allison@lohutok.net>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH v2] libertas: Fix a double free in if_spi_c2h_data()
Date: Fri, 05 Jul 2019 11:42:48 -0500	[thread overview]
Message-ID: <ee4472e4728becc9713962ba264742cb1f337098.camel@redhat.com> (raw)
In-Reply-To: <e679c9f99d6952f82924c71f036e4a196d0e72d4.camel@redhat.com>

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>
---
 drivers/net/wireless/marvell/libertas/if_spi.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/net/wireless/marvell/libertas/if_spi.c b/drivers/net/wireless/marvell/libertas/if_spi.c
index 27067e79e83fe..072da89c4986f 100644
--- a/drivers/net/wireless/marvell/libertas/if_spi.c
+++ b/drivers/net/wireless/marvell/libertas/if_spi.c
@@ -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;
+	/* lbs_process_rxed_packet() consumes the skb */
 
-	/* success */
-	goto out;
-
-free_skb:
-	dev_kfree_skb(skb);
 out:
 	if (err)
 		netdev_err(priv->dev, "%s: err=%d\n", __func__, err);
-- 
2.20.1


  reply	other threads:[~2019-07-05 16:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-26 10:09 [PATCH] libertas: Fix a double free in if_spi_c2h_data() Dan Carpenter
2019-06-26 13:16 ` Dan Williams
2019-06-26 13:23   ` Dan Carpenter
2019-06-26 16:02     ` Dan Williams
2019-07-05 16:42       ` Dan Williams [this message]
2019-07-24 11:46         ` [PATCH v2] " Kalle Valo
2019-07-24 14:38         ` [PATCH v3] " Dan Williams
2019-08-06 12:36           ` Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee4472e4728becc9713962ba264742cb1f337098.camel@redhat.com \
    --to=dcbw@redhat.com \
    --cc=allison@lohutok.net \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvalo@codeaurora.org \
    --cc=libertas-dev@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lkundrak@v3.sk \
    --cc=prakity@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).