hwmon: (gpd-fan) Fix error handling in gpd_fan_probe()

devm_request_region() returns a NULL pointer on error, not an ERR_PTR().
Handle it accordingly.

Also fix error return from the call to devm_hwmon_device_register_with_info().

Fixes: 0ab88e2394 ("hwmon: add GPD devices sensor driver")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Cryolitia PukNgae <cryolitia@uniontech.com>
Link: https://lore.kernel.org/r/20251010204447.94343-1-harshit.m.mogalapalli@oracle.com
[groeck: Updated subject to improve readability]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Harshit Mogalapalli 2025-10-10 13:44:46 -07:00 committed by Guenter Roeck
parent ab0fd09d25
commit 72ac148510

View File

@ -621,8 +621,8 @@ static int gpd_fan_probe(struct platform_device *pdev)
region = devm_request_region(dev, res->start,
resource_size(res), DRIVER_NAME);
if (IS_ERR(region))
return dev_err_probe(dev, PTR_ERR(region),
if (!region)
return dev_err_probe(dev, -EBUSY,
"Failed to request region\n");
hwdev = devm_hwmon_device_register_with_info(dev,
@ -631,7 +631,7 @@ static int gpd_fan_probe(struct platform_device *pdev)
&gpd_fan_chip_info,
NULL);
if (IS_ERR(hwdev))
return dev_err_probe(dev, PTR_ERR(region),
return dev_err_probe(dev, PTR_ERR(hwdev),
"Failed to register hwmon device\n");
return 0;