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: Ubuntu-5.11.0-14.15~37 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=dc28f71f637a8344d7da97d908ba498346f16552;hp=26ab3f79e38e5ef33b3fc63ef78290c4dd13e65a;p=mirror_ubuntu-hirsute-kernel.git extcon: Fix error handling in extcon_dev_register BugLink: https://bugs.launchpad.net/bugs/1923069 [ Upstream commit d3bdd1c3140724967ca4136755538fa7c05c2b4e ] 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 Signed-off-by: Sasha Levin Signed-off-by: Andrea Righi --- diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 0a6438cbb3f3..e7a9561a826d 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; }