isdn: mISDN: Fix potential NULL pointer dereference of kzalloc
authorAditya Pakki <pakki001@umn.edu>
Sat, 2 Mar 2019 21:20:43 +0000 (15:20 -0600)
committerDavid S. Miller <davem@davemloft.net>
Mon, 4 Mar 2019 18:54:48 +0000 (10:54 -0800)
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>
drivers/isdn/hardware/mISDN/hfcsusb.c

index 124ff53..26e3182 100644 (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;