This is a note to let you know that I've just added the patch titled extcon: Fix error handling in extcon_dev_register to the 4.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: extcon-fix-error-handling-in-extcon_dev_register.patch and it can be found in the queue-4.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit af07ca6a82e96d32ad0df3785acf0806c91f1135 Author: Dinghao Liu <dinghao.liu@xxxxxxxxxx> Date: Tue Jan 19 16:10:55 2021 +0800 extcon: Fix error handling in extcon_dev_register [ 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 <dinghao.liu@xxxxxxxxxx> Signed-off-by: Chanwoo Choi <cw00.choi@xxxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 95e96f04bf6f..e9fe3e3bac2b 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1252,6 +1252,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; }