linux/drivers/memstick/core
Greg Kroah-Hartman 4b6d621c9d memstick: fix memory leak if card device is never registered
When calling dev_set_name() memory is allocated for the name for the
struct device.  Once that structure device is registered, or attempted
to be registerd, with the driver core, the driver core will handle
cleaning up that memory when the device is removed from the system.

Unfortunatly for the memstick code, there is an error path that causes
the struct device to never be registered, and so the memory allocated in
dev_set_name will be leaked.  Fix that leak by manually freeing it right
before the memory for the device is freed.

Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Cc: Alex Dubov <oakad@yahoo.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: linux-mmc@vger.kernel.org
Fixes: 0252c3b4f0 ("memstick: struct device - replace bus_id with dev_name(), dev_set_name()")
Cc: stable <stable@kernel.org>
Co-developed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Co-developed-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Signed-off-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Link: https://lore.kernel.org/r/20230401200327.16800-1-gregkh@linuxfoundation.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
2023-04-05 11:43:51 +02:00
..
Kconfig memstick: core: Imply IOSCHED_BFQ 2023-02-02 16:02:06 +01:00
Makefile treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
memstick.c memstick: fix memory leak if card device is never registered 2023-04-05 11:43:51 +02:00
ms_block.c memstick/ms_block: Add check for alloc_ordered_workqueue 2022-12-07 13:29:14 +01:00
ms_block.h memstick/ms_block: simplify refcounting 2022-02-16 19:44:24 -07:00
mspro_block.c memstick/mspro_block: Convert to use sysfs_emit()/sysfs_emit_at() APIs 2022-12-09 10:29:58 +01:00