Skip to content

Commit d0e5102

Browse files
Yang Yinglianggroeck
authored andcommitted
hwmon: (ibmaem) don't call platform_device_del() if platform_device_add() fails
If platform_device_add() fails, it no need to call platform_device_del(), split platform_device_unregister() into platform_device_del/put(), so platform_device_put() can be called separately. Fixes: 8808a79 ("ibmaem: new driver for power/energy/temp meters in IBM System X hardware") Reported-by: Hulk Robot <[email protected]> Signed-off-by: Yang Yingliang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent f0aa153 commit d0e5102

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/hwmon/ibmaem.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
550550

551551
res = platform_device_add(data->pdev);
552552
if (res)
553-
goto ipmi_err;
553+
goto dev_add_err;
554554

555555
platform_set_drvdata(data->pdev, data);
556556

@@ -598,7 +598,9 @@ static int aem_init_aem1_inst(struct aem_ipmi_data *probe, u8 module_handle)
598598
ipmi_destroy_user(data->ipmi.user);
599599
ipmi_err:
600600
platform_set_drvdata(data->pdev, NULL);
601-
platform_device_unregister(data->pdev);
601+
platform_device_del(data->pdev);
602+
dev_add_err:
603+
platform_device_put(data->pdev);
602604
dev_err:
603605
ida_free(&aem_ida, data->id);
604606
id_err:
@@ -690,7 +692,7 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
690692

691693
res = platform_device_add(data->pdev);
692694
if (res)
693-
goto ipmi_err;
695+
goto dev_add_err;
694696

695697
platform_set_drvdata(data->pdev, data);
696698

@@ -738,7 +740,9 @@ static int aem_init_aem2_inst(struct aem_ipmi_data *probe,
738740
ipmi_destroy_user(data->ipmi.user);
739741
ipmi_err:
740742
platform_set_drvdata(data->pdev, NULL);
741-
platform_device_unregister(data->pdev);
743+
platform_device_del(data->pdev);
744+
dev_add_err:
745+
platform_device_put(data->pdev);
742746
dev_err:
743747
ida_free(&aem_ida, data->id);
744748
id_err:

0 commit comments

Comments
 (0)