mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] extcon: Fix error handling in extcon_dev_register
@ 2021-01-19  8:10 Dinghao Liu
  2021-02-26  6:04 ` Chanwoo Choi
  0 siblings, 1 reply; 2+ messages in thread
From: Dinghao Liu @ 2021-01-19  8:10 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: MyungJoo Ham, Chanwoo Choi, Krzysztof Kozlowski, linux-kernel

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@zju.edu.cn>
---
 drivers/extcon/extcon.c | 1 +
 1 file changed, 1 insertion(+)

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;
 	}
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] extcon: Fix error handling in extcon_dev_register
  2021-01-19  8:10 [PATCH] extcon: Fix error handling in extcon_dev_register Dinghao Liu
@ 2021-02-26  6:04 ` Chanwoo Choi
  0 siblings, 0 replies; 2+ messages in thread
From: Chanwoo Choi @ 2021-02-26  6:04 UTC (permalink / raw)
  To: Dinghao Liu, kjlu
  Cc: MyungJoo Ham, Chanwoo Choi, Krzysztof Kozlowski, linux-kernel

Hi,

On 21. 1. 19. 오후 5:10, Dinghao Liu wrote:
> 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@zju.edu.cn>
> ---
>   drivers/extcon/extcon.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> 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;
>   	}
>   
> 

Thanks for fixup. Applied it.

Thanks,
Chanwoo Choi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-26  6:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-19  8:10 [PATCH] extcon: Fix error handling in extcon_dev_register Dinghao Liu
2021-02-26  6:04 ` Chanwoo Choi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®