From: Guenter Roeck Date: Wed, 10 Aug 2016 05:34:31 +0000 (-0700) Subject: watchdog: core: Fix devres_alloc() allocation size X-Git-Tag: v4.8.9~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=66503ec38f3419b7e0d75ac4d9267c9e95539066;p=thirdparty%2Fkernel%2Fstable.git watchdog: core: Fix devres_alloc() allocation size commit 2e91838bf7ffdedabdb29e091207d6531d04ef4f upstream. 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 Signed-off-by: Guenter Roeck Acked-by: Neil Armstrong Signed-off-by: Wim Van Sebroeck Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c index 6abb83cd76810..74265b2f806ca 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;