netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Aditya Pakki <pakki001@umn.edu>
Cc: kjlu@umn.edu, Karsten Keil <isdn@linux-pingi.de>,
	"David S. Miller" <davem@davemloft.net>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] isdn: mISDN: Fix potential NULL pointer dereference of kzalloc
Date: Sat, 2 Mar 2019 15:26:09 -0600	[thread overview]
Message-ID: <939bbac6-2fa4-c3f4-2b8b-b3498cb31c6d@embeddedor.com> (raw)
In-Reply-To: <20190302212044.13638-1-pakki001@umn.edu>



On 3/2/19 3:20 PM, Aditya Pakki wrote:
> Allocating memory via kzalloc for phi may fail and causes a
> NULL pointer dereference. This patch avoids such a scenario.
> 

Was this detected by Coccinelle?

If so, please mention it in the commit log.

Thanks
--
Gustavo

> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  drivers/isdn/hardware/mISDN/hfcsusb.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/isdn/hardware/mISDN/hfcsusb.c b/drivers/isdn/hardware/mISDN/hfcsusb.c
> index 124ff530da82..26e3182bbca8 100644
> --- a/drivers/isdn/hardware/mISDN/hfcsusb.c
> +++ b/drivers/isdn/hardware/mISDN/hfcsusb.c
> @@ -263,6 +263,9 @@ hfcsusb_ph_info(struct hfcsusb *hw)
>  	int i;
>  
>  	phi = kzalloc(struct_size(phi, bch, dch->dev.nrbchan), GFP_ATOMIC);
> +	if (!phi)
> +		return;
> +
>  	phi->dch.ch.protocol = hw->protocol;
>  	phi->dch.ch.Flags = dch->Flags;
>  	phi->dch.state = dch->state;
> 

  reply	other threads:[~2019-03-02 21:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-02 21:20 [PATCH] isdn: mISDN: Fix potential NULL pointer dereference of kzalloc Aditya Pakki
2019-03-02 21:26 ` Gustavo A. R. Silva [this message]
2019-03-02 21:39   ` Kangjie Lu
2019-03-04 18:55 ` David Miller

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=939bbac6-2fa4-c3f4-2b8b-b3498cb31c6d@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=bigeasy@linutronix.de \
    --cc=davem@davemloft.net \
    --cc=isdn@linux-pingi.de \
    --cc=kjlu@umn.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pakki001@umn.edu \
    /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).