Skip to content

Commit

Permalink
hwmon: (amd_energy) Missing platform_driver_unregister() on error in …
Browse files Browse the repository at this point in the history
…amd_energy_init()

Add the missing platform_driver_unregister() before return
from amd_energy_init() in the error handling case.

Fixes: 8abee95 ("hwmon: Add amd_energy driver to report energy counters")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Acked-by: Naveen krishna Chatradhi <nchatrad@amd.com>
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Link: https://lore.kernel.org/r/20200527022417.105620-1-weiyongjun1@huawei.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Wei Yongjun authored and Guenter Roeck committed May 27, 2020
1 parent 8054ead commit 59dd36f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/hwmon/amd_energy.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,10 @@ static int __init amd_energy_init(void)
return ret;

amd_energy_platdev = platform_device_alloc(DRVNAME, 0);
if (!amd_energy_platdev)
if (!amd_energy_platdev) {
platform_driver_unregister(&amd_energy_driver);
return -ENOMEM;
}

ret = platform_device_add(amd_energy_platdev);
if (ret) {
Expand Down

0 comments on commit 59dd36f

Please sign in to comment.