diff mbox

brcmfmac: fix txglomming scatter-gather packet transfers

Message ID 20140306060936.GB26578@redhat.com
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Dave Jones March 6, 2014, 6:09 a.m. UTC
On Wed, Mar 05, 2014 at 07:26:36PM +0000, Linux Kernel wrote:
 
 > Commit:     1eb43018673e735ea9cd756970f4e71ca01a5f21
 > Parent:     21f8aaee0c62708654988ce092838aa7df4d25d8
 > Author:     Arend van Spriel <arend@broadcom.com>
 > AuthorDate: Thu Feb 20 18:55:55 2014 +0100
 > Committer:  John W. Linville <linville@tuxdriver.com>
 > CommitDate: Thu Feb 20 15:53:20 2014 -0500
 > 
 >     brcmfmac: fix txglomming scatter-gather packet transfers

Coverity just flagged this code.

 >  	if (skb_tailroom(pkt) < tail_pad && pkt->len > blksize) {
 > +		pkt_pad = brcmu_pkt_buf_get_skb(tail_pad + tail_chop +
 > +						bus->head_align);
 >  		if (pkt_pad == NULL)
 >  			return -ENOMEM;
 >  		ret = brcmf_sdio_txpkt_hdalign(bus, pkt_pad);

Right after this, I think we need the diff below or we leak pkt_pad.
If this looks right, I'll submit it properly tomorrow.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Arend van Spriel March 6, 2014, 8:51 a.m. UTC | #1
On 03/06/2014 07:09 AM, Dave Jones wrote:
> On Wed, Mar 05, 2014 at 07:26:36PM +0000, Linux Kernel wrote:
>  
>  > Commit:     1eb43018673e735ea9cd756970f4e71ca01a5f21
>  > Parent:     21f8aaee0c62708654988ce092838aa7df4d25d8
>  > Author:     Arend van Spriel <arend@broadcom.com>
>  > AuthorDate: Thu Feb 20 18:55:55 2014 +0100
>  > Committer:  John W. Linville <linville@tuxdriver.com>
>  > CommitDate: Thu Feb 20 15:53:20 2014 -0500
>  > 
>  >     brcmfmac: fix txglomming scatter-gather packet transfers
> 
> Coverity just flagged this code.
> 
>  >  	if (skb_tailroom(pkt) < tail_pad && pkt->len > blksize) {
>  > +		pkt_pad = brcmu_pkt_buf_get_skb(tail_pad + tail_chop +
>  > +						bus->head_align);
>  >  		if (pkt_pad == NULL)
>  >  			return -ENOMEM;
>  >  		ret = brcmf_sdio_txpkt_hdalign(bus, pkt_pad);
> 
> Right after this, I think we need the diff below or we leak pkt_pad.
> If this looks right, I'll submit it properly tomorrow.

Looks right to me so go ahead.

Regards,
Arend

> diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> index 119ee6eaf1c3..ddaa9efd053d 100644
> --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
> @@ -1948,8 +1948,10 @@ static int brcmf_sdio_txpkt_prep_sg(struct brcmf_sdio *bus,
>  		if (pkt_pad == NULL)
>  			return -ENOMEM;
>  		ret = brcmf_sdio_txpkt_hdalign(bus, pkt_pad);
> -		if (unlikely(ret < 0))
> +		if (unlikely(ret < 0)) {
> +			kfree_skb(pkt_pad);
>  			return ret;
> +		}
>  		memcpy(pkt_pad->data,
>  		       pkt->data + pkt->len - tail_chop,
>  		       tail_chop);
> 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
index 119ee6eaf1c3..ddaa9efd053d 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c
@@ -1948,8 +1948,10 @@  static int brcmf_sdio_txpkt_prep_sg(struct brcmf_sdio *bus,
 		if (pkt_pad == NULL)
 			return -ENOMEM;
 		ret = brcmf_sdio_txpkt_hdalign(bus, pkt_pad);
-		if (unlikely(ret < 0))
+		if (unlikely(ret < 0)) {
+			kfree_skb(pkt_pad);
 			return ret;
+		}
 		memcpy(pkt_pad->data,
 		       pkt->data + pkt->len - tail_chop,
 		       tail_chop);