Skip to content

Commit

Permalink
isdn: mISDN: Fix potential NULL pointer dereference of kzalloc
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Aditya Pakki authored and davem330 committed Mar 4, 2019
1 parent 72d8b4f commit 38d2265
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/isdn/hardware/mISDN/hfcsusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 38d2265

Please sign in to comment.