Patch "memstick: fix memory leak if card device is never registered" has been added to the 6.2-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    memstick: fix memory leak if card device is never registered

to the 6.2-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     memstick-fix-memory-leak-if-card-device-is-never-registered.patch
and it can be found in the queue-6.2 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From 4b6d621c9d859ff89e68cebf6178652592676013 Mon Sep 17 00:00:00 2001
From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 1 Apr 2023 22:03:27 +0200
Subject: memstick: fix memory leak if card device is never registered

From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

commit 4b6d621c9d859ff89e68cebf6178652592676013 upstream.

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@xxxxxxxxx>
Cc: Alex Dubov <oakad@xxxxxxxxx>
Cc: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
Cc: Hans de Goede <hdegoede@xxxxxxxxxx>
Cc: Kay Sievers <kay.sievers@xxxxxxxx>
Cc: linux-mmc@xxxxxxxxxxxxxxx
Fixes: 0252c3b4f018 ("memstick: struct device - replace bus_id with dev_name(), dev_set_name()")
Cc: stable <stable@xxxxxxxxxx>
Co-developed-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Co-developed-by: Mirsad Goran Todorovac <mirsad.todorovac@xxxxxxxxxxxx>
Signed-off-by: Mirsad Goran Todorovac <mirsad.todorovac@xxxxxxxxxxxx>
Link: https://lore.kernel.org/r/20230401200327.16800-1-gregkh@xxxxxxxxxxxxxxxxxxx
Signed-off-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/memstick/core/memstick.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

--- a/drivers/memstick/core/memstick.c
+++ b/drivers/memstick/core/memstick.c
@@ -410,6 +410,7 @@ static struct memstick_dev *memstick_all
 	return card;
 err_out:
 	host->card = old_card;
+	kfree_const(card->dev.kobj.name);
 	kfree(card);
 	return NULL;
 }
@@ -468,8 +469,10 @@ static void memstick_check(struct work_s
 				put_device(&card->dev);
 				host->card = NULL;
 			}
-		} else
+		} else {
+			kfree_const(card->dev.kobj.name);
 			kfree(card);
+		}
 	}
 
 out_power_off:


Patches currently in stable-queue which might be from gregkh@xxxxxxxxxxxxxxxxxxx are

queue-6.2/iio-light-tsl2772-fix-reading-proximity-diodes-from-device-tree.patch
queue-6.2/iio-dac-ad5755-add-missing-fwnode_handle_put.patch
queue-6.2/revert-acpica-events-support-fixed-pcie-wake-event.patch
queue-6.2/memstick-fix-memory-leak-if-card-device-is-never-registered.patch
queue-6.2/mptcp-stops-worker-on-unaccepted-sockets-at-listener-close.patch
queue-6.2/pwm-zero-initialize-the-pwm_state-passed-to-driver-s-.get_state.patch
queue-6.2/loongarch-mark-3-symbol-exports-as-non-gpl.patch
queue-6.2/loongarch-fix-probing-of-the-crc32-feature.patch
queue-6.2/revert-userfaultfd-don-t-fail-on-unrecognized-features.patch
queue-6.2/loongarch-check-unwind_error-in-arch_stack_walk.patch
queue-6.2/nilfs2-initialize-unused-bytes-in-segment-summary-blocks.patch
queue-6.2/btrfs-reinterpret-async-discard-iops_limit-0-as-no-delay.patch
queue-6.2/mtd-spi-nor-fix-memory-leak-when-using-debugfs_looku.patch
queue-6.2/wifi-ath9k-don-t-mark-channelmap-stack-variable-read-only-in-ath9k_mci_update_wlan_channels.patch
queue-6.2/loongarch-module-set-section-addresses-to-0x0.patch
queue-6.2/mptcp-fix-accept-vs-worker-race.patch
queue-6.2/asoc-sof-ipc4-topology-clarify-bind-failure-caused-by-missing-fw_module.patch
queue-6.2/writeback-cgroup-fix-null-ptr-deref-write-in-bdi_split_work_to_wbs.patch
queue-6.2/btrfs-set-default-discard-iops_limit-to-1000.patch
queue-6.2/rust-kernel-mark-rust_fmt_argument-as-extern-c.patch
queue-6.2/alsa-hda-realtek-fix-mute-micmute-leds-for-a-hp-probook.patch
queue-6.2/maple_tree-make-maple-state-reusable-after-mas_empty_area_rev.patch
queue-6.2/maple_tree-fix-a-potential-memory-leak-oob-access-or-other-unpredictable-bug.patch
queue-6.2/kernel-sys.c-fix-and-improve-control-flow-in-__sys_setresid.patch
queue-6.2/maple_tree-fix-mas_empty_area-search.patch
queue-6.2/tools-mm-page_owner_sort.c-fix-tgid-output-when-cull-tg-is-used.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux