]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hwmon: (gpd-fan) Fix error handling in gpd_fan_probe()
authorHarshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Fri, 10 Oct 2025 20:44:46 +0000 (13:44 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 20 Oct 2025 01:56:14 +0000 (18:56 -0700)
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: 0ab88e239439 ("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>
drivers/hwmon/gpd-fan.c

index eebe39ef967775238e8ff5a2a4d223f2ee3e1339..321794807e8d856dcfcb271baf63d36b4f58c994 100644 (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;