2022-07-22 09:56:25

by williamsukatube

[permalink] [raw]
Subject: [PATCH] watchdog: f71808e_wdt: Add check for platform_driver_register

From: William Dean <[email protected]>

As platform_driver_register() could fail, it should be better
to deal with the return value in order to maintain the code
consisitency.

Fixes: 27e0fe00a5c61 ("watchdog: f71808e_wdt: refactor to platform device/driver pair")
Reported-by: Hacash Robot <[email protected]>
Signed-off-by: William Dean <[email protected]>
---
drivers/watchdog/f71808e_wdt.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/f71808e_wdt.c b/drivers/watchdog/f71808e_wdt.c
index 7f59c680de25..6a16d3d0bb1e 100644
--- a/drivers/watchdog/f71808e_wdt.c
+++ b/drivers/watchdog/f71808e_wdt.c
@@ -634,7 +634,9 @@ static int __init fintek_wdt_init(void)

pdata.type = ret;

- platform_driver_register(&fintek_wdt_driver);
+ ret = platform_driver_register(&fintek_wdt_driver);
+ if (ret)
+ return ret;

wdt_res.name = "superio port";
wdt_res.flags = IORESOURCE_IO;
--
2.25.1


2022-07-22 14:30:46

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH] watchdog: f71808e_wdt: Add check for platform_driver_register

On 7/22/22 02:25, [email protected] wrote:
> From: William Dean <[email protected]>
>
> As platform_driver_register() could fail, it should be better
> to deal with the return value in order to maintain the code
> consisitency.
>
> Fixes: 27e0fe00a5c61 ("watchdog: f71808e_wdt: refactor to platform device/driver pair")
> Reported-by: Hacash Robot <[email protected]>
> Signed-off-by: William Dean <[email protected]>

Reviewed-by: Guenter Roeck <[email protected]>

> ---
> drivers/watchdog/f71808e_wdt.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/f71808e_wdt.c b/drivers/watchdog/f71808e_wdt.c
> index 7f59c680de25..6a16d3d0bb1e 100644
> --- a/drivers/watchdog/f71808e_wdt.c
> +++ b/drivers/watchdog/f71808e_wdt.c
> @@ -634,7 +634,9 @@ static int __init fintek_wdt_init(void)
>
> pdata.type = ret;
>
> - platform_driver_register(&fintek_wdt_driver);
> + ret = platform_driver_register(&fintek_wdt_driver);
> + if (ret)
> + return ret;
>
> wdt_res.name = "superio port";
> wdt_res.flags = IORESOURCE_IO;