isdn: mISDN: Fix potential NULL pointer dereference of kzalloc

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Aditya Pakki 2019-03-02 15:20:43 -06:00 committed by David S. Miller
parent 72d8b4fdbf
commit 38d2265980
1 changed files with 3 additions and 0 deletions

View File

@ -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;