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

can: softing_cs: softingcs_probe(): fix memleak on registration failure

In case device registration fails during probe, the driver state and
the embedded platform device structure needs to be freed using
platform_device_put() to properly free all resources (e.g. the device
name).

Fixes: 0a0b7a5f7a04 ("can: add driver for Softing card")
Link: https://lore.kernel.org/all/20211222104843.6105-1-johan@kernel.org
Cc: stable@vger.kernel.org # 2.6.38
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Johan Hovold and committed by
Marc Kleine-Budde
ced4913e 6dc9a23e

+1 -1
+1 -1
drivers/net/can/softing/softing_cs.c
··· 293 293 return 0; 294 294 295 295 platform_failed: 296 - kfree(dev); 296 + platform_device_put(pdev); 297 297 mem_failed: 298 298 pcmcia_bad: 299 299 pcmcia_failed: