linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] brcmfmac: testing the wrong variable in brcmf_rx_hdrpull()
@ 2016-04-19 14:25 Dan Carpenter
  2016-04-20  8:31 ` Arend Van Spriel
  2016-04-26  9:30 ` Kalle Valo
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2016-04-19 14:25 UTC (permalink / raw)
  To: Brett Rudley, Arend van Spriel
  Cc: Franky (Zhenhui) Lin, Hante Meuleman, Kalle Valo,
	Pieter-Paul Giesberts, Franky Lin, linux-wireless,
	brcm80211-dev-list, kernel-janitors

Smatch complains about this code:

    drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c:335 brcmf_rx_hdrpull()
    error: we previously assumed '*ifp' could be null (see line 333)

The problem is that we recently changed these from "ifp" to "*ifp" but
there was one that we didn't update.

-       if (ret || !ifp || !ifp->ndev) {
+       if (ret || !(*ifp) || !(*ifp)->ndev) {
                if (ret != -ENODATA && ifp)
                                       ^^^
-                       ifp->stats.rx_errors++;
+                       (*ifp)->stats.rx_errors++;

I have updated it to *ifp as well.  We always call this function is a
non-NULL "ifp" pointer, btw.

Fixes: c462ebcdfe42 ('brcmfmac: create common function for handling brcmf_proto_hdrpull()')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index 1b476d1..b590499 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -331,7 +331,7 @@ static int brcmf_rx_hdrpull(struct brcmf_pub *drvr, struct sk_buff *skb,
 	ret = brcmf_proto_hdrpull(drvr, true, skb, ifp);
 
 	if (ret || !(*ifp) || !(*ifp)->ndev) {
-		if (ret != -ENODATA && ifp)
+		if (ret != -ENODATA && *ifp)
 			(*ifp)->stats.rx_errors++;
 		brcmu_pkt_buf_free_skb(skb);
 		return -ENODATA;

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

* Re: [patch] brcmfmac: testing the wrong variable in brcmf_rx_hdrpull()
  2016-04-19 14:25 [patch] brcmfmac: testing the wrong variable in brcmf_rx_hdrpull() Dan Carpenter
@ 2016-04-20  8:31 ` Arend Van Spriel
  2016-04-26  9:30 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Arend Van Spriel @ 2016-04-20  8:31 UTC (permalink / raw)
  To: Dan Carpenter, Brett Rudley, Arend van Spriel
  Cc: Franky (Zhenhui) Lin, Hante Meuleman, Kalle Valo,
	Pieter-Paul Giesberts, Franky Lin, linux-wireless,
	brcm80211-dev-list, kernel-janitors

On 19-4-2016 16:25, Dan Carpenter wrote:
> Smatch complains about this code:
> 
>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c:335 brcmf_rx_hdrpull()
>     error: we previously assumed '*ifp' could be null (see line 333)
> 
> The problem is that we recently changed these from "ifp" to "*ifp" but
> there was one that we didn't update.
> 
> -       if (ret || !ifp || !ifp->ndev) {
> +       if (ret || !(*ifp) || !(*ifp)->ndev) {
>                 if (ret != -ENODATA && ifp)
>                                        ^^^
> -                       ifp->stats.rx_errors++;
> +                       (*ifp)->stats.rx_errors++;
> 
> I have updated it to *ifp as well.  We always call this function is a
> non-NULL "ifp" pointer, btw.

Great. Maybe we (Broadcom) should consider running smatch on our patch
series or simply rely on your excellent work :-p. Thanks for catching this.

Acked-by: Arend van Spriel <arend@broadcom.com>
> Fixes: c462ebcdfe42 ('brcmfmac: create common function for handling brcmf_proto_hdrpull()')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
> index 1b476d1..b590499 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
> @@ -331,7 +331,7 @@ static int brcmf_rx_hdrpull(struct brcmf_pub *drvr, struct sk_buff *skb,
>  	ret = brcmf_proto_hdrpull(drvr, true, skb, ifp);
>  
>  	if (ret || !(*ifp) || !(*ifp)->ndev) {
> -		if (ret != -ENODATA && ifp)
> +		if (ret != -ENODATA && *ifp)
>  			(*ifp)->stats.rx_errors++;
>  		brcmu_pkt_buf_free_skb(skb);
>  		return -ENODATA;
> 

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

* Re: brcmfmac: testing the wrong variable in brcmf_rx_hdrpull()
  2016-04-19 14:25 [patch] brcmfmac: testing the wrong variable in brcmf_rx_hdrpull() Dan Carpenter
  2016-04-20  8:31 ` Arend Van Spriel
@ 2016-04-26  9:30 ` Kalle Valo
  1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2016-04-26  9:30 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Brett Rudley, Arend van Spriel, Franky (Zhenhui) Lin,
	Hante Meuleman, Pieter-Paul Giesberts, Franky Lin, linux-wireless,
	brcm80211-dev-list, kernel-janitors


> Smatch complains about this code:
> 
>     drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c:335 brcmf_rx_hdrpull()
>     error: we previously assumed '*ifp' could be null (see line 333)
> 
> The problem is that we recently changed these from "ifp" to "*ifp" but
> there was one that we didn't update.
> 
> -       if (ret || !ifp || !ifp->ndev) {
> +       if (ret || !(*ifp) || !(*ifp)->ndev) {
>                 if (ret != -ENODATA && ifp)
>                                        ^^^
> -                       ifp->stats.rx_errors++;
> +                       (*ifp)->stats.rx_errors++;
> 
> I have updated it to *ifp as well.  We always call this function is a
> non-NULL "ifp" pointer, btw.
> 
> Fixes: c462ebcdfe42 ('brcmfmac: create common function for handling brcmf_proto_hdrpull()')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Acked-by: Arend van Spriel <arend@broadcom.com>

Thanks, applied to wireless-drivers-next.git.

Kalle Valo

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

end of thread, other threads:[~2016-04-26  9:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-19 14:25 [patch] brcmfmac: testing the wrong variable in brcmf_rx_hdrpull() Dan Carpenter
2016-04-20  8:31 ` Arend Van Spriel
2016-04-26  9:30 ` Kalle Valo

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