From 9558ed0cf5a021ae9b3d66a17f75607d9f477d41 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 15 Jan 2021 12:56:17 +0100 Subject: [PATCH] 4.19-stable patches added patches: regmap-debugfs-fix-a-reversed-if-statement-in-regmap_debugfs_init.patch --- ...-if-statement-in-regmap_debugfs_init.patch | 37 +++++++++++++++++++ queue-4.19/series | 1 + 2 files changed, 38 insertions(+) create mode 100644 queue-4.19/regmap-debugfs-fix-a-reversed-if-statement-in-regmap_debugfs_init.patch diff --git a/queue-4.19/regmap-debugfs-fix-a-reversed-if-statement-in-regmap_debugfs_init.patch b/queue-4.19/regmap-debugfs-fix-a-reversed-if-statement-in-regmap_debugfs_init.patch new file mode 100644 index 00000000000..f4f64374954 --- /dev/null +++ b/queue-4.19/regmap-debugfs-fix-a-reversed-if-statement-in-regmap_debugfs_init.patch @@ -0,0 +1,37 @@ +From f6bcb4c7f366905b66ce8ffca7190118244bb642 Mon Sep 17 00:00:00 2001 +From: Dan Carpenter +Date: Tue, 5 Jan 2021 14:42:29 +0300 +Subject: regmap: debugfs: Fix a reversed if statement in regmap_debugfs_init() + +From: Dan Carpenter + +commit f6bcb4c7f366905b66ce8ffca7190118244bb642 upstream. + +This code will leak "map->debugfs_name" because the if statement is +reversed so it only frees NULL pointers instead of non-NULL. In +fact the if statement is not required and should just be removed +because kfree() accepts NULL pointers. + +Fixes: cffa4b2122f5 ("regmap: debugfs: Fix a memory leak when calling regmap_attach_dev") +Signed-off-by: Dan Carpenter +Link: https://lore.kernel.org/r/X/RQpfAwRdLg0GqQ@mwanda +Signed-off-by: Mark Brown +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/base/regmap/regmap-debugfs.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +--- a/drivers/base/regmap/regmap-debugfs.c ++++ b/drivers/base/regmap/regmap-debugfs.c +@@ -591,9 +591,7 @@ void regmap_debugfs_init(struct regmap * + } + + if (!strcmp(name, "dummy")) { +- if (!map->debugfs_name) +- kfree(map->debugfs_name); +- ++ kfree(map->debugfs_name); + map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d", + dummy_index); + if (!map->debugfs_name) diff --git a/queue-4.19/series b/queue-4.19/series index e00d16a5d39..d9e97bb14a3 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -40,3 +40,4 @@ wan-ds26522-select-config_bitreverse.patch kvm-arm64-don-t-access-pmcr_el0-when-no-pmu-is-available.patch block-fix-use-after-free-in-disk_part_iter_next.patch net-drop-bogus-skb-with-checksum_partial-and-offset-beyond-end-of-trimmed-packet.patch +regmap-debugfs-fix-a-reversed-if-statement-in-regmap_debugfs_init.patch -- 2.47.3