bgmac: fix a missing check for build_skb
Subsystems (3)
when build_skb failed, it may occure a NULL pointer. So add a 'NULL check' for it.
--- drivers/net/ethernet/broadcom/bgmac.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/broadcom/bgmac.c +5 -0
@@ -466,6 +466,11 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, len -=ETH_FCS_LEN ; skb =build_skb (buf,BGMAC_RX_ALLOC_SIZE ); +if (unlikely (skb)) { +bgmac_err (bgmac,"build_skb failed\n" ); +put_page (virt_to_head_page (buf)); +break ; + }skb_put (skb,BGMAC_RX_FRAME_OFFSET +BGMAC_RX_BUF_OFFSET + len); skb_pull(skb, BGMAC_RX_FRAME_OFFSET +
Signature · 1 line
1.9.0
From: Weidong Wang <[email protected]>
Date: Wed, 13 Jan 2016 11:06:41 +0800
Quoted 4 lines
when
build_skbfailed, it may occure a NULL pointer. So add a 'NULL check' for it.Signed-off-by Weidong Wang <[email protected]>
Applied, thanks.
Paolo Abeni
maintainerQuoted 13 lines · Weidong Wang
when
build_skbfailed, it may occure a NULL pointer. So add a 'NULL check' for it.Signed-off-by Weidong Wang <[email protected]>--- drivers/net/ethernet/broadcom/bgmac.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/ethernet/broadcom/bgmac.c +0
-0
drivers/net/ethernet/broadcom/bgmac.c static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, · line 469
Quoted 4 lines
drivers/net/ethernet/broadcom/bgmac.c +1
-0@@ -466,6 +466,11 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, len -=ETH_FCS_LEN ; skb =build_skb (buf,BGMAC_RX_ALLOC_SIZE ); +if (unlikely (skb)) {
Should that be instead:
if (unlikely(!skb)) {
?
Quoted 7 lines
drivers/net/ethernet/broadcom/bgmac.c +4
-0+bgmac_err (bgmac,"build_skb failed\n" ); +put_page (virt_to_head_page (buf)); +break ; + }skb_put (skb,BGMAC_RX_FRAME_OFFSET +BGMAC_RX_BUF_OFFSET + len); skb_pull(skb, BGMAC_RX_FRAME_OFFSET +
Quoted 16 lines · Paolo Abeni
Quoted 15 lines · Weidong Wang
when
build_skbfailed, it may occure a NULL pointer. So add a 'NULL check' for it.Signed-off-by Weidong Wang <[email protected]>--- drivers/net/ethernet/broadcom/bgmac.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/ethernet/broadcom/bgmac.c +0
-0@@ -466,6 +466,11 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, len -=ETH_FCS_LEN ;
Quoted 9 lines
drivers/net/ethernet/broadcom/bgmac.c static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, · line 469
Quoted 2 lines
drivers/net/ethernet/broadcom/bgmac.c +1
-0skb =build_skb (buf,BGMAC_RX_ALLOC_SIZE ); +if (unlikely (skb)) {Should that be instead:
if (unlikely(!skb)) {
?
What to instead of it?
Regards,
Weidong
Quoted 11 lines
drivers/net/ethernet/broadcom/bgmac.c static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, · line 476
Quoted 7 lines
drivers/net/ethernet/broadcom/bgmac.c +4
-0+bgmac_err (bgmac,"build_skb failed\n" ); +put_page (virt_to_head_page (buf)); +break ; + }skb_put (skb,BGMAC_RX_FRAME_OFFSET +BGMAC_RX_BUF_OFFSET + len); skb_pull(skb, BGMAC_RX_FRAME_OFFSET +.
Quoted 22 lines · Weidong Wang
Quoted 21 lines · Paolo Abeni
Quoted 13 lines · Weidong Wang
when
build_skbfailed, it may occure a NULL pointer. So add a 'NULL check' for it.Signed-off-by Weidong Wang <[email protected]>--- drivers/net/ethernet/broadcom/bgmac.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/ethernet/broadcom/bgmac.c +0
-0drivers/net/ethernet/broadcom/bgmac.c static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, · line 469
Quoted 4 lines
drivers/net/ethernet/broadcom/bgmac.c +1
-0@@ -466,6 +466,11 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, len -=ETH_FCS_LEN ; skb =build_skb (buf,BGMAC_RX_ALLOC_SIZE ); +if (unlikely (skb)) {Should that be instead:
Quoted 6 lines
Quoted 4 lines
if (unlikely(!skb)) {
?
What to instead of it?
Your patch has a logic error (missing the !), and it's breaking the ethernet driver completely instead of fixing anything. Did you even test this?
Dave, why did you apply this patch so fast without any chance of review?
- Felix
Quoted 25 lines · Felix Fietkau
Quoted 24 lines · Weidong Wang
Quoted 23 lines · Paolo Abeni
Quoted 13 lines · Weidong Wang
when
build_skbfailed, it may occure a NULL pointer. So add a 'NULL check' for it.Signed-off-by Weidong Wang <[email protected]>--- drivers/net/ethernet/broadcom/bgmac.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/ethernet/broadcom/bgmac.c +0
-0drivers/net/ethernet/broadcom/bgmac.c static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, · line 469
Quoted 4 lines
drivers/net/ethernet/broadcom/bgmac.c +1
-0@@ -466,6 +466,11 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, len -=ETH_FCS_LEN ; skb =build_skb (buf,BGMAC_RX_ALLOC_SIZE ); +if (unlikely (skb)) {Should that be instead:
if (unlikely(!skb)) {
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
?
What to instead of it?
Your patch has a logic error (missing the !), and it's breaking the ethernet driver completely instead of fixing anything. Did you even test this?
Yep, you are right.
Sorry for that.
I just review the source code without any test.
I should resent it again.
Quoted 6 lines
Dave, why did you apply this patch so fast without any chance of review?
- Felix
.
Regards,
Weidong
David Miller
maintainerFrom: Felix Fietkau <[email protected]>
Date: Wed, 13 Jan 2016 11:57:51 +0100
Quoted 2 lines
Dave, why did you apply this patch so fast without any chance of review?
Because I wanted to clear my backlog %100 for the merge window initial pull request.
The patch looked simple enough, I did read it carefully, and I did unfortunately miss the logic error.
PATCH v2 1/1 bgmac: fix a missing check for build_skb
In reply to Weidong Wangwhen build_skb failed, it may occur a NULL pointer. So add a 'NULL check' for it.
---
change log:
v2:
fix the error logic change which pointed by Paolo Abni and Felix.
--- drivers/net/ethernet/broadcom/bgmac.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/ethernet/broadcom/bgmac.c +5 -0
@@ -466,6 +466,11 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, len -=ETH_FCS_LEN ; skb =build_skb (buf,BGMAC_RX_ALLOC_SIZE ); +if (unlikely (!skb)) { +bgmac_err (bgmac,"build_skb failed\n" ); +put_page (virt_to_head_page (buf)); +break ; + }skb_put (skb,BGMAC_RX_FRAME_OFFSET +BGMAC_RX_BUF_OFFSET + len); skb_pull(skb, BGMAC_RX_FRAME_OFFSET +
Signature · 1 line
1.9.0
Quoted 9 lines · Weidong Wang
when
build_skbfailed, it may occur a NULL pointer. So add a 'NULL check' for it.Signed-off-by Weidong Wang <[email protected]>---
change log:
v2:
fix the error logic change which pointed by Paolo Abni and Felix.
This is too late, you have to send a relative patch, since the prior one was merged.
Quoted 11 lines · Eric Dumazet
Quoted 9 lines · Weidong Wang
when
build_skbfailed, it may occur a NULL pointer. So add a 'NULL check' for it.Signed-off-by Weidong Wang <[email protected]>---
change log:
v2:
fix the error logic change which pointed by Paolo Abni and Felix.
Quoted 4 lines
This is too late, you have to send a relative patch, since the prior one was merged.
OK.
Regards,
Weidong
Quoted 2 lines
Hello.
Quoted 13 lines · Weidong Wang
when
build_skbfailed, it may occure a NULL pointer. So add a 'NULL check' for it.Signed-off-by Weidong Wang <[email protected]>--- drivers/net/ethernet/broadcom/bgmac.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/net/ethernet/broadcom/bgmac.c +0
-0
drivers/net/ethernet/broadcom/bgmac.c static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, · line 469
Quoted 4 lines
drivers/net/ethernet/broadcom/bgmac.c +1
-0@@ -466,6 +466,11 @@ static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, len -=ETH_FCS_LEN ; skb =build_skb (buf,BGMAC_RX_ALLOC_SIZE ); +if (unlikely (skb)) {
!skb , you mean?
drivers/net/ethernet/broadcom/bgmac.c static int bgmac_dma_rx_read(struct bgmac *bgmac, struct bgmac_dma_ring *ring, · line 476
Quoted 7 lines
drivers/net/ethernet/broadcom/bgmac.c +4
-0+bgmac_err (bgmac,"build_skb failed\n" ); +put_page (virt_to_head_page (buf)); +break ; + }skb_put (skb,BGMAC_RX_FRAME_OFFSET +BGMAC_RX_BUF_OFFSET + len); skb_pull(skb, BGMAC_RX_FRAME_OFFSET +
MBR, Sergei