Centos-kernel-stream-9/drivers/memstick/core
Desnes Nunes bf3c785da2 memstick: fix memory leak if card device is never registered
JIRA: https://issues.redhat.com/browse/RHEL-34114

commit 4b6d621c9d859ff89e68cebf6178652592676013
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Sat, 1 Apr 2023 22:03:27 +0200

  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>

Signed-off-by: Desnes Nunes <desnesn@redhat.com>
2024-05-20 13:28:42 -03:00
..
Kconfig memstick: core: Imply IOSCHED_BFQ 2024-05-20 13:28:42 -03:00
Makefile
memstick.c memstick: fix memory leak if card device is never registered 2024-05-20 13:28:42 -03:00
ms_block.c block: simplify disk shutdown 2022-10-12 09:20:15 +08:00
ms_block.h memstick/ms_block: simplify refcounting 2022-06-22 08:57:51 +08:00
mspro_block.c memstick/mspro_block: Convert to use sysfs_emit()/sysfs_emit_at() APIs 2024-05-20 13:28:42 -03:00