Skip to contentSkip to conversation

brcmfmac: fix txglomming scatter-gather packet transfers

DISCUSSION Dave Jones 3 participants 6 messages Mar 6, 2014 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Dave Jones

author
#1 lore raw
In reply to a message not in the archive
Quoted 8 lines · Linux Kernel
Commit:     1eb43018673e735ea9cd756970f4e71ca01a5f21
Parent:     21f8aaee0c62708654988ce092838aa7df4d25d8
Author:     Arend van Spriel <[email protected]>
AuthorDate: Thu Feb 20 18:55:55 2014 +0100
Committer:  John W. Linville <[email protected]>
CommitDate: Thu Feb 20 15:53:20 2014 -0500

brcmfmac: fix txglomming scatter-gather packet transfers

Coverity just flagged this code.

Review

Quoted 6 lines
(quoted diff) +2 -0
 	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.

drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +3 -1
index 119ee6eaf1c3..ddaa9efd053d 100644
@@ -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);
#2 lore raw
Quoted 13 lines · Dave Jones
Quoted 8 lines · Linux Kernel
Commit:     1eb43018673e735ea9cd756970f4e71ca01a5f21
Parent:     21f8aaee0c62708654988ce092838aa7df4d25d8
Author:     Arend van Spriel <[email protected]>
AuthorDate: Thu Feb 20 18:55:55 2014 +0100
Committer:  John W. Linville <[email protected]>
CommitDate: Thu Feb 20 15:53:20 2014 -0500

brcmfmac: fix txglomming scatter-gather packet transfers

Coverity just flagged this code.

Quoted 9 lines

drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c static int brcmf_sdio_txpkt_prep_sg(struct brcmf_sdio *bus, · line 1950

Quoted 6 lines
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +2 -0
 	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

Quoted 17 lines
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +3 -1
index 119ee6eaf1c3..ddaa9efd053d 100644
@@ -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);
author
#3 lore raw

brcmfmac: fix skb leak in brcmf_sdio_txpkt_prep_sg error path.

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 <[email protected]>
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +3 -1
index 119ee6eaf1c3..ddaa9efd053d 100644
@@ -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);
#4 lore raw

Re: brcmfmac: fix skb leak in brcmf_sdio_txpkt_prep_sg error path.

- netdev
+ linux-wireless

Quoted 3 lines · Dave Jones

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<[email protected]>
+ Acked-by: Arend van Spriel <[email protected]

Quoted 1 line

---
I guess you intend John to take this patch, right?

Regards,
Arend

Quoted 18 lines
drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +3 -1
index 119ee6eaf1c3..ddaa9efd053d 100644
@@ -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);
author
#6 lore raw

brcmfmac: fix skb leak in brcmf_sdio_txpkt_prep_sg error path.

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.

drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +3 -1
index 119ee6eaf1c3..ddaa9efd053d 100644
@@ -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);