extcon: Fix error handling in extcon_dev_register
[ Upstream commitd3bdd1c314
] When devm_kcalloc() fails, we should execute device_unregister() to unregister edev->dev from system. Fixes:046050f6e6
("extcon: Update the prototype of extcon_register_notifier() with enum extcon") Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
869d286703
commit
6e65e0fbe1
@ -1200,6 +1200,7 @@ int extcon_dev_register(struct extcon_dev *edev)
|
|||||||
sizeof(*edev->nh) * edev->max_supported, GFP_KERNEL);
|
sizeof(*edev->nh) * edev->max_supported, GFP_KERNEL);
|
||||||
if (!edev->nh) {
|
if (!edev->nh) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
device_unregister(&edev->dev);
|
||||||
goto err_dev;
|
goto err_dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user