Skip to contentSkip to conversation

Extcon: check for allocation failure

PATCH New Dan Carpenter 1 participant 1 message Apr 25, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Extcon: check for allocation failure

Return -ENOMEM if the kmalloc() fails.

drivers/extcon/extcon_class.c +2 -0
index 3bc4b8a..fe5a038 100644
@@ -621,6 +621,8 @@ int extcon_dev_register(struct extcon_dev *edev, struct device *dev)
 	}
 
 	edev->dev = kzalloc(sizeof(struct device), GFP_KERNEL);
+	if (!edev->dev)
+		return -ENOMEM;
 	edev->dev->parent = dev;
 	edev->dev->class = extcon_class;
 	edev->dev->release = extcon_dev_release;