Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: core: Fix devres_alloc() allocation size

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>
Acked-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by

Guenter Roeck and committed by
Wim Van Sebroeck
2e91838b 3be79886

+1 -1
+1 -1
drivers/watchdog/watchdog_core.c
··· 349 349 struct watchdog_device **rcwdd; 350 350 int ret; 351 351 352 - rcwdd = devres_alloc(devm_watchdog_unregister_device, sizeof(*wdd), 352 + rcwdd = devres_alloc(devm_watchdog_unregister_device, sizeof(*rcwdd), 353 353 GFP_KERNEL); 354 354 if (!rcwdd) 355 355 return -ENOMEM;