From: Dinghao Liu Date: Tue, 19 Jan 2021 08:10:55 +0000 (+0800) Subject: extcon: Fix error handling in extcon_dev_register X-Git-Tag: accepted/tizen/unified/20230118.172025~7540^2~5^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d3bdd1c3140724967ca4136755538fa7c05c2b4e;p=platform%2Fkernel%2Flinux-rpi.git extcon: Fix error handling in extcon_dev_register When devm_kcalloc() fails, we should execute device_unregister() to unregister edev->dev from system. Fixes: 046050f6e623e ("extcon: Update the prototype of extcon_register_notifier() with enum extcon") Signed-off-by: Dinghao Liu Signed-off-by: Chanwoo Choi --- diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 0a6438c..e7a9561 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1241,6 +1241,7 @@ int extcon_dev_register(struct extcon_dev *edev) sizeof(*edev->nh), GFP_KERNEL); if (!edev->nh) { ret = -ENOMEM; + device_unregister(&edev->dev); goto err_dev; }