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

mfd: dm355evm_msp: Return directly after a failed platform_device_alloc() in add_child()

The platform_device_put() function was called in one case by the
add_child() function during error handling even if the passed
variable "pdev" contained a null pointer.
Return directly in this case.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Markus Elfring and committed by
Lee Jones
d313cdde 8175a01c

+2 -5
+2 -5
drivers/mfd/dm355evm_msp.c
··· 199 199 int status; 200 200 201 201 pdev = platform_device_alloc(name, -1); 202 - if (!pdev) { 203 - dev_dbg(&client->dev, "can't alloc dev\n"); 204 - status = -ENOMEM; 205 - goto err; 206 - } 202 + if (!pdev) 203 + return ERR_PTR(-ENOMEM); 207 204 208 205 device_init_wakeup(&pdev->dev, can_wakeup); 209 206 pdev->dev.parent = &client->dev;