From a1d26ac0ddc4ea561e17a75dd3b5f9d3c1812f16 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 25 Apr 2012 11:47:02 +0300 Subject: [PATCH] Extcon: check for allocation failure Return -ENOMEM if the kmalloc() fails. Signed-off-by: Dan Carpenter Acked-by: MyungJoo Ham Signed-off-by: Greg Kroah-Hartman --- drivers/extcon/extcon_class.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/extcon/extcon_class.c b/drivers/extcon/extcon_class.c index dbd3bfba42da..53c64a98b0be 100644 --- a/drivers/extcon/extcon_class.c +++ b/drivers/extcon/extcon_class.c @@ -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; -- 2.30.2