* [PATCH v2] watchdog: ie6xx_wdt: Check for null res pointer
@ 2021-12-20 6:21 Jiasheng Jiang
2021-12-20 15:41 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2021-12-20 6:21 UTC (permalink / raw)
To: wim, linux; +Cc: linux-watchdog, linux-kernel, Jiasheng Jiang
The return value of platform_get_resource() needs to be checked.
To avoid use of error pointer in case that there is no suitable resource.
Fixes: 101ce87b3bdd ("watchdog: Add watchdog driver for Intel Atom E6XX")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
Changelog:
v1 -> v2
*Change 1. Correct the commit message.
---
drivers/watchdog/ie6xx_wdt.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/watchdog/ie6xx_wdt.c b/drivers/watchdog/ie6xx_wdt.c
index 8f28993fab8b..ee5b68d2e271 100644
--- a/drivers/watchdog/ie6xx_wdt.c
+++ b/drivers/watchdog/ie6xx_wdt.c
@@ -271,6 +271,9 @@ static int ie6xx_wdt_remove(struct platform_device *pdev)
struct resource *res;
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+ if (!res)
+ return -EINVAL;
+
ie6xx_wdt_stop(NULL);
watchdog_unregister_device(&ie6xx_wdt_dev);
ie6xx_wdt_debugfs_exit();
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] watchdog: ie6xx_wdt: Check for null res pointer
2021-12-20 6:21 [PATCH v2] watchdog: ie6xx_wdt: Check for null res pointer Jiasheng Jiang
@ 2021-12-20 15:41 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2021-12-20 15:41 UTC (permalink / raw)
To: Jiasheng Jiang, wim; +Cc: linux-watchdog, linux-kernel
On 12/19/21 10:21 PM, Jiasheng Jiang wrote:
> The return value of platform_get_resource() needs to be checked.
> To avoid use of error pointer in case that there is no suitable resource.
>
How would that resource disappear since the probe function ?
That driver could use a lot of cleanup (use devm_request_region(),
use watchdog_stop_on_unregister(), stop using a static data structure,
use devm_add_action_or_reset to trigger the call to debugfs_remove,
use devm_watchdog_register_device and drop the remove function),
but this change addresses a non-existing problem.
Guenter
> Fixes: 101ce87b3bdd ("watchdog: Add watchdog driver for Intel Atom E6XX")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> Changelog:
>
> v1 -> v2
>
> *Change 1. Correct the commit message.
> ---
> drivers/watchdog/ie6xx_wdt.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/watchdog/ie6xx_wdt.c b/drivers/watchdog/ie6xx_wdt.c
> index 8f28993fab8b..ee5b68d2e271 100644
> --- a/drivers/watchdog/ie6xx_wdt.c
> +++ b/drivers/watchdog/ie6xx_wdt.c
> @@ -271,6 +271,9 @@ static int ie6xx_wdt_remove(struct platform_device *pdev)
> struct resource *res;
>
> res = platform_get_resource(pdev, IORESOURCE_IO, 0);
> + if (!res)
> + return -EINVAL;
> +
> ie6xx_wdt_stop(NULL);
> watchdog_unregister_device(&ie6xx_wdt_dev);
> ie6xx_wdt_debugfs_exit();
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-20 15:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-20 6:21 [PATCH v2] watchdog: ie6xx_wdt: Check for null res pointer Jiasheng Jiang
2021-12-20 15:41 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).