linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Lamparter <chunkeey@googlemail.com>
To: Myungho Jung <mhjungk@gmail.com>
Cc: netdev@vger.kernel.org, David Miller <davem@redhat.com>,
	linux-wireless@vger.kernel.org
Subject: Re: [PATCH] p54: add null pointer check before releasing socket buffer
Date: Mon, 10 Apr 2017 14:12:54 +0200	[thread overview]
Message-ID: <3716717.OUypxXNBrR@debian64> (raw)
In-Reply-To: <1491801800-4371-1-git-send-email-mhjungk@gmail.com>

(Added linux-wireless, since this is a wireless driver)

On Sunday, April 9, 2017 10:23:20 PM CEST Myungho Jung wrote:
> Kernel panic is caused by trying to dereference null pointer. Check if
> the pointer is null before freeing space.
Do you have the kernel panic somewhere?
I think you have an even bigger problem: You see, in order to get EEPROM
readback and rx_stats feedback you need to sent a request to the firmware
and if the response's req_id cookies don't match, you end up filling up 
the very limited device address space.

As for adding if (!skb) checks. I think kfree, kfree_skb, dev_kfree_skb 
(aka consume_skb) all check for null pointers already. So the logical
thing to do would be to make dev_kfree_skb_irq (which would also fix
dev_kfree_skb_any) consistent with kfree, kfree_skb, dev_kfree_skb and
add the check there.

> Signed-off-by: Myungho Jung <mhjungk@gmail.com>
> ---
>  drivers/net/wireless/intersil/p54/txrx.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/intersil/p54/txrx.c b/drivers/net/wireless/intersil/p54/txrx.c
> index 1af7da0..8956061 100644
> --- a/drivers/net/wireless/intersil/p54/txrx.c
> +++ b/drivers/net/wireless/intersil/p54/txrx.c
> @@ -503,7 +503,9 @@ static void p54_rx_eeprom_readback(struct p54_common *priv,
>  
>  	priv->eeprom = NULL;
>  	tmp = p54_find_and_unlink_skb(priv, hdr->req_id);
> -	dev_kfree_skb_any(tmp);
> +	if (unlikely(!tmp))
> +		dev_kfree_skb_any(tmp);
> +
>  	complete(&priv->eeprom_comp);
>  }
>  
> @@ -597,7 +599,9 @@ static void p54_rx_stats(struct p54_common *priv, struct sk_buff *skb)
>  	}
>  
>  	tmp = p54_find_and_unlink_skb(priv, hdr->req_id);
> -	dev_kfree_skb_any(tmp);
> +	if (unlikely(!tmp))
> +		dev_kfree_skb_any(tmp);
> +
>  	complete(&priv->stat_comp);
>  }
>  
> 

       reply	other threads:[~2017-04-10 12:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1491801800-4371-1-git-send-email-mhjungk@gmail.com>
2017-04-10 12:12 ` Christian Lamparter [this message]
2017-04-10 20:54   ` [PATCH] p54: add null pointer check before releasing socket buffer Myungho Jung
2017-04-10 21:22     ` Christian Lamparter
2017-04-10 21:38       ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3716717.OUypxXNBrR@debian64 \
    --to=chunkeey@googlemail.com \
    --cc=davem@redhat.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mhjungk@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).