Skip to contentSkip to conversation

mISDN: correctly handling failed allocation

PATCH In review Insu Yun 2 participants 2 messages Dec 29, 2015 – Jan 4, 2016

Subsystems (2)
lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 mISDN: correctly handling failed allocation

Since kzalloc can be failed in memory pressure,
NULL dereference might be happened.

---
 drivers/isdn/hardware/mISDN/hfcsusb.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/isdn/hardware/mISDN/hfcsusb.c +3 -0
index 114f3bc..15164e9 100644
@@ -264,6 +264,9 @@ hfcsusb_ph_info(struct hfcsusb *hw)
 
 	phi = kzalloc(sizeof(struct ph_info) +
 		      dch->dev.nrbchan * sizeof(struct ph_info_ch), GFP_ATOMIC);
+	if (!phi)
+		return;
+
 	phi->dch.ch.protocol = hw->protocol;
 	phi->dch.ch.Flags = dch->Flags;
 	phi->dch.state = dch->state;
Signature · 1 line
1.9.1
maintainer
#1 lore raw

From: Insu Yun <[email protected]>
Date: Tue, 29 Dec 2015 16:38:46 -0500

Quoted 4 lines

Since kzalloc can be failed in memory pressure,
NULL dereference might be happened.

Sorry, this is not a correct fix.

You need to propagate an error back to the callers, and they must act upon that error.