* [PATCH] isdn: mISDN: Fix potential NULL pointer dereference of kzalloc
@ 2019-03-02 21:20 Aditya Pakki
2019-03-02 21:26 ` Gustavo A. R. Silva
2019-03-04 18:55 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Aditya Pakki @ 2019-03-02 21:20 UTC (permalink / raw)
To: pakki001
Cc: kjlu, Karsten Keil, David S. Miller, Gustavo A. R. Silva,
Sebastian Andrzej Siewior, netdev, linux-kernel
Allocating memory via kzalloc for phi may fail and causes a
NULL pointer dereference. This patch avoids such a scenario.
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;
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] isdn: mISDN: Fix potential NULL pointer dereference of kzalloc
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
2019-03-02 21:39 ` Kangjie Lu
2019-03-04 18:55 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Gustavo A. R. Silva @ 2019-03-02 21:26 UTC (permalink / raw)
To: Aditya Pakki
Cc: kjlu, Karsten Keil, David S. Miller, Sebastian Andrzej Siewior,
netdev, linux-kernel
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;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] isdn: mISDN: Fix potential NULL pointer dereference of kzalloc
2019-03-02 21:26 ` Gustavo A. R. Silva
@ 2019-03-02 21:39 ` Kangjie Lu
0 siblings, 0 replies; 4+ messages in thread
From: Kangjie Lu @ 2019-03-02 21:39 UTC (permalink / raw)
To: Gustavo A. R. Silva, Aditya Pakki
Cc: Karsten Keil, David S. Miller, Sebastian Andrzej Siewior, netdev,
linux-kernel
On 3/2/19 3:26 PM, Gustavo A. R. Silva wrote:
>
> 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?
It was detected by an LLVM-based static analyzer we recently developed.
>
> 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;
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] isdn: mISDN: Fix potential NULL pointer dereference of kzalloc
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
@ 2019-03-04 18:55 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-03-04 18:55 UTC (permalink / raw)
To: pakki001; +Cc: kjlu, isdn, gustavo, bigeasy, netdev, linux-kernel
From: Aditya Pakki <pakki001@umn.edu>
Date: Sat, 2 Mar 2019 15:20:43 -0600
> Allocating memory via kzalloc for phi may fail and causes a
> NULL pointer dereference. This patch avoids such a scenario.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Applied.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-03-04 18:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2019-03-02 21:39 ` Kangjie Lu
2019-03-04 18:55 ` David Miller
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).