mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] watchdog: core: Fix devres_alloc() allocation size
@ 2016-08-10  5:34 Guenter Roeck
  2016-08-11  8:36 ` Neil Armstrong
  0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2016-08-10  5:34 UTC (permalink / raw)
  To: Wim Van Sebroeck
  Cc: linux-watchdog, linux-kernel, Guenter Roeck, Neil Armstrong

Coverity reports:

Passing argument 152UL /* sizeof (*wdd) */ to function __devres_alloc_node
and then casting the return value to struct watchdog_device ** is
suspicious.

Allocation size needs to be sizeof(*rcwdd), not sizeof(*wdd).

Fixes: 83fbae5a148c ("watchdog: Add a device managed API for ...")
Cc: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/watchdog_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
index 6abb83cd7681..74265b2f806c 100644
--- a/drivers/watchdog/watchdog_core.c
+++ b/drivers/watchdog/watchdog_core.c
@@ -349,7 +349,7 @@ int devm_watchdog_register_device(struct device *dev,
 	struct watchdog_device **rcwdd;
 	int ret;
 
-	rcwdd = devres_alloc(devm_watchdog_unregister_device, sizeof(*wdd),
+	rcwdd = devres_alloc(devm_watchdog_unregister_device, sizeof(*rcwdd),
 			     GFP_KERNEL);
 	if (!rcwdd)
 		return -ENOMEM;
-- 
2.5.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] watchdog: core: Fix devres_alloc() allocation size
  2016-08-10  5:34 [PATCH] watchdog: core: Fix devres_alloc() allocation size Guenter Roeck
@ 2016-08-11  8:36 ` Neil Armstrong
  0 siblings, 0 replies; 2+ messages in thread
From: Neil Armstrong @ 2016-08-11  8:36 UTC (permalink / raw)
  To: Guenter Roeck, Wim Van Sebroeck; +Cc: linux-watchdog, linux-kernel

On 08/10/2016 07:34 AM, Guenter Roeck wrote:
> Coverity reports:
> 
> Passing argument 152UL /* sizeof (*wdd) */ to function __devres_alloc_node
> and then casting the return value to struct watchdog_device ** is
> suspicious.
> 
> Allocation size needs to be sizeof(*rcwdd), not sizeof(*wdd).
> 
> Fixes: 83fbae5a148c ("watchdog: Add a device managed API for ...")
> Cc: Neil Armstrong <narmstrong@baylibre.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/watchdog/watchdog_core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
> index 6abb83cd7681..74265b2f806c 100644
> --- a/drivers/watchdog/watchdog_core.c
> +++ b/drivers/watchdog/watchdog_core.c
> @@ -349,7 +349,7 @@ int devm_watchdog_register_device(struct device *dev,
>  	struct watchdog_device **rcwdd;
>  	int ret;
>  
> -	rcwdd = devres_alloc(devm_watchdog_unregister_device, sizeof(*wdd),
> +	rcwdd = devres_alloc(devm_watchdog_unregister_device, sizeof(*rcwdd),
>  			     GFP_KERNEL);
>  	if (!rcwdd)
>  		return -ENOMEM;
> 

My bad...

Acked-by: Neil Armstrong <narmstrong@baylibre.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-11  8:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-10  5:34 [PATCH] watchdog: core: Fix devres_alloc() allocation size Guenter Roeck
2016-08-11  8:36 ` Neil Armstrong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome