netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: brcmfmac: fix txglomming scatter-gather packet transfers
       [not found] <20140305192636.D06AA660D72@gitolite.kernel.org>
@ 2014-03-06  6:09 ` Dave Jones
  2014-03-06  8:51   ` Arend van Spriel
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Jones @ 2014-03-06  6:09 UTC (permalink / raw)
  To: netdev; +Cc: arend, linville, linux-coverity

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.

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);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: brcmfmac: fix txglomming scatter-gather packet transfers
  2014-03-06  6:09 ` brcmfmac: fix txglomming scatter-gather packet transfers Dave Jones
@ 2014-03-06  8:51   ` Arend van Spriel
  2014-03-06 17:03     ` brcmfmac: fix skb leak in brcmf_sdio_txpkt_prep_sg error path Dave Jones
  0 siblings, 1 reply; 5+ messages in thread
From: Arend van Spriel @ 2014-03-06  8:51 UTC (permalink / raw)
  To: Dave Jones, netdev; +Cc: linville, linux-coverity

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);
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* brcmfmac: fix skb leak in brcmf_sdio_txpkt_prep_sg error path.
  2014-03-06  8:51   ` Arend van Spriel
@ 2014-03-06 17:03     ` Dave Jones
  2014-03-06 21:41       ` Sergei Shtylyov
  0 siblings, 1 reply; 5+ messages in thread
From: Dave Jones @ 2014-03-06 17:03 UTC (permalink / raw)
  To: Arend van Spriel; +Cc: netdev, linville, linux-coverity

Commit 1eb4301867 added an allocation of an skb via brcmu_pkt_buf_get_skb()
but forgot to free it on one of the error paths.
 
Cc: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Dave Jones <davej@fedoraproject.org>

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);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* brcmfmac: fix skb leak in brcmf_sdio_txpkt_prep_sg error path.
  2014-03-06 21:41       ` Sergei Shtylyov
@ 2014-03-06 20:51         ` Dave Jones
  0 siblings, 0 replies; 5+ messages in thread
From: Dave Jones @ 2014-03-06 20:51 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Arend van Spriel, netdev, linville, linux-coverity

Commit 1eb4301867 (brcmfmac: fix txglomming scatter-gather packet transfers)
added an allocation of an skb via brcmu_pkt_buf_get_skb() but forgot to
free it on one of the error paths.

Acked-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Dave Jones<davej@fedoraproject.org>

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);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: brcmfmac: fix skb leak in brcmf_sdio_txpkt_prep_sg error path.
  2014-03-06 17:03     ` brcmfmac: fix skb leak in brcmf_sdio_txpkt_prep_sg error path Dave Jones
@ 2014-03-06 21:41       ` Sergei Shtylyov
  2014-03-06 20:51         ` Dave Jones
  0 siblings, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2014-03-06 21:41 UTC (permalink / raw)
  To: Dave Jones, Arend van Spriel; +Cc: netdev, linville, linux-coverity

Hello.

On 03/06/2014 08:03 PM, Dave Jones wrote:

> Commit 1eb4301867 added an allocation of an skb via brcmu_pkt_buf_get_skb()

    Please also specify that commit's summary line is parens.

> but forgot to free it on one of the error paths.

> Cc: Arend van Spriel <arend@broadcom.com>
> Signed-off-by: Dave Jones <davej@fedoraproject.org>

WBR, Sergei

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-03-06 20:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20140305192636.D06AA660D72@gitolite.kernel.org>
2014-03-06  6:09 ` brcmfmac: fix txglomming scatter-gather packet transfers Dave Jones
2014-03-06  8:51   ` Arend van Spriel
2014-03-06 17:03     ` brcmfmac: fix skb leak in brcmf_sdio_txpkt_prep_sg error path Dave Jones
2014-03-06 21:41       ` Sergei Shtylyov
2014-03-06 20:51         ` Dave Jones

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).