Skip to content

Commit

Permalink
extcon: Fix error handling in extcon_dev_register
Browse files Browse the repository at this point in the history
[ Upstream commit d3bdd1c3140724967ca4136755538fa7c05c2b4e ]

When devm_kcalloc() fails, we should execute device_unregister()
to unregister edev->dev from system.

Fixes: 046050f ("extcon: Update the prototype of extcon_register_notifier() with enum extcon")
Signed-off-by: Dinghao Liu <[email protected]>
Signed-off-by: Chanwoo Choi <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
dinghaoliu authored and gregkh committed Apr 7, 2021
1 parent 869d286 commit 6e65e0f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions drivers/extcon/extcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ int extcon_dev_register(struct extcon_dev *edev)
sizeof(*edev->nh) * edev->max_supported, GFP_KERNEL);
if (!edev->nh) {
ret = -ENOMEM;
device_unregister(&edev->dev);
goto err_dev;
}

Expand Down

0 comments on commit 6e65e0f

Please sign in to comment.