Skip to content

Commit

Permalink
extcon: Fix error handling in extcon_dev_register
Browse files Browse the repository at this point in the history
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 <dinghao.liu@zju.edu.cn>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
  • Loading branch information
Dinghao Liu authored and Chanwoo Choi committed Mar 15, 2021
1 parent c9570d4 commit d3bdd1c
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 @@ -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;
}

Expand Down

0 comments on commit d3bdd1c

Please sign in to comment.