* [PATCH] hwmon: gpd-fan: Fix error handling in gpd_fan_probe()
@ 2025-10-10 20:44 Harshit Mogalapalli
2025-10-11 6:16 ` Cryolitia PukNgae
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Harshit Mogalapalli @ 2025-10-10 20:44 UTC (permalink / raw)
To: Cryolitia PukNgae, Guenter Roeck, linux-hwmon, linux-kernel
Cc: dan.carpenter, kernel-janitors, error27, harshit.m.mogalapalli
When devm_request_region(0 fails to get a region regrion would be NULL
and devm_hwmon_device_register_with_info() fails, best to propagate
the hwmon dev to PTR_ERR() as opposed to region.
Fixes: 0ab88e239439 ("hwmon: add GPD devices sensor driver")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
This is based on static analysis with Smatch, only compile tested.
---
drivers/hwmon/gpd-fan.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/gpd-fan.c b/drivers/hwmon/gpd-fan.c
index eebe39ef9677..321794807e8d 100644
--- a/drivers/hwmon/gpd-fan.c
+++ b/drivers/hwmon/gpd-fan.c
@@ -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;
--
2.39.3
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hwmon: gpd-fan: Fix error handling in gpd_fan_probe()
2025-10-10 20:44 [PATCH] hwmon: gpd-fan: Fix error handling in gpd_fan_probe() Harshit Mogalapalli
@ 2025-10-11 6:16 ` Cryolitia PukNgae
2025-10-12 17:19 ` Markus Elfring
2025-10-12 17:58 ` Guenter Roeck
2 siblings, 0 replies; 4+ messages in thread
From: Cryolitia PukNgae @ 2025-10-11 6:16 UTC (permalink / raw)
To: Harshit Mogalapalli, Guenter Roeck, linux-hwmon, linux-kernel,
cryolitia.pukngae
Cc: dan.carpenter, kernel-janitors, error27
On 11/10/2025 04.44, Harshit Mogalapalli wrote:
> When devm_request_region(0 fails to get a region regrion would be NULL
> and devm_hwmon_device_register_with_info() fails, best to propagate
> the hwmon dev to PTR_ERR() as opposed to region.
>
> Fixes: 0ab88e239439 ("hwmon: add GPD devices sensor driver")
> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
> This is based on static analysis with Smatch, only compile tested.
> ---
> drivers/hwmon/gpd-fan.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hwmon/gpd-fan.c b/drivers/hwmon/gpd-fan.c
> index eebe39ef9677..321794807e8d 100644
> --- a/drivers/hwmon/gpd-fan.c
> +++ b/drivers/hwmon/gpd-fan.c
> @@ -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;
Reviewed-by: Cryolitia PukNgae <cryolitia@uniontech.com>
thx
Best regards
Cryolitia PukNgae
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hwmon: gpd-fan: Fix error handling in gpd_fan_probe()
2025-10-10 20:44 [PATCH] hwmon: gpd-fan: Fix error handling in gpd_fan_probe() Harshit Mogalapalli
2025-10-11 6:16 ` Cryolitia PukNgae
@ 2025-10-12 17:19 ` Markus Elfring
2025-10-12 17:58 ` Guenter Roeck
2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2025-10-12 17:19 UTC (permalink / raw)
To: Harshit Mogalapalli, linux-hwmon, Cryolitia PukNgae,
Günter Röck
Cc: kernel-janitors, LKML, Dan Carpenter, Dan Carpenter
> When devm_request_region(0 fails to get a region regrion would be NULL
> and devm_hwmon_device_register_with_info() fails, best to propagate
> the hwmon dev to PTR_ERR() as opposed to region.
Will another imperative wording approach become more helpful for an improved
change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17#n94
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hwmon: gpd-fan: Fix error handling in gpd_fan_probe()
2025-10-10 20:44 [PATCH] hwmon: gpd-fan: Fix error handling in gpd_fan_probe() Harshit Mogalapalli
2025-10-11 6:16 ` Cryolitia PukNgae
2025-10-12 17:19 ` Markus Elfring
@ 2025-10-12 17:58 ` Guenter Roeck
2 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2025-10-12 17:58 UTC (permalink / raw)
To: Harshit Mogalapalli
Cc: Cryolitia PukNgae, linux-hwmon, linux-kernel, dan.carpenter,
kernel-janitors, error27
On Fri, Oct 10, 2025 at 01:44:46PM -0700, Harshit Mogalapalli wrote:
> When devm_request_region(0 fails to get a region regrion would be NULL
> and devm_hwmon_device_register_with_info() fails, best to propagate
> the hwmon dev to PTR_ERR() as opposed to region.
>
> 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>
> ---
Appied after updating the subject.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-12 17:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-10 20:44 [PATCH] hwmon: gpd-fan: Fix error handling in gpd_fan_probe() Harshit Mogalapalli
2025-10-11 6:16 ` Cryolitia PukNgae
2025-10-12 17:19 ` Markus Elfring
2025-10-12 17:58 ` Guenter Roeck
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®