Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-08-16 22:01:45 +0200
committerJiri Slaby <jslaby@suse.cz>2019-08-16 22:25:10 +0200
commit4bcc02cae521466b61202c40588dc41f2d9448b9 (patch)
tree230f5eb330b0ac8d3e96ae3748b08f9926521f37
parentd83beba5bb37d65fba4995c25f31a3d414a5acf8 (diff)
test_firmware: fix a memory leak bug (bnc#1012628).
-rw-r--r--patches.kernel.org/5.2.9-110-test_firmware-fix-a-memory-leak-bug.patch49
-rw-r--r--series.conf1
2 files changed, 50 insertions, 0 deletions
diff --git a/patches.kernel.org/5.2.9-110-test_firmware-fix-a-memory-leak-bug.patch b/patches.kernel.org/5.2.9-110-test_firmware-fix-a-memory-leak-bug.patch
new file mode 100644
index 0000000000..0873235534
--- /dev/null
+++ b/patches.kernel.org/5.2.9-110-test_firmware-fix-a-memory-leak-bug.patch
@@ -0,0 +1,49 @@
+From: Wenwen Wang <wenwen@cs.uga.edu>
+Date: Sun, 14 Jul 2019 01:11:35 -0500
+Subject: [PATCH] test_firmware: fix a memory leak bug
+References: bnc#1012628
+Patch-mainline: 5.2.9
+Git-commit: d4fddac5a51c378c5d3e68658816c37132611e1f
+
+[ Upstream commit d4fddac5a51c378c5d3e68658816c37132611e1f ]
+
+In test_firmware_init(), the buffer pointed to by the global pointer
+'test_fw_config' is allocated through kzalloc(). Then, the buffer is
+initialized in __test_firmware_config_init(). In the case that the
+initialization fails, the following execution in test_firmware_init() needs
+to be terminated with an error code returned to indicate this failure.
+However, the allocated buffer is not freed on this execution path, leading
+to a memory leak bug.
+
+To fix the above issue, free the allocated buffer before returning from
+test_firmware_init().
+
+Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
+Link: https://lore.kernel.org/r/1563084696-6865-1-git-send-email-wang6495@umn.edu
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Sasha Levin <sashal@kernel.org>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ lib/test_firmware.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/lib/test_firmware.c b/lib/test_firmware.c
+index 83ea6c4e623c..6ca97a63b3d6 100644
+--- a/lib/test_firmware.c
++++ b/lib/test_firmware.c
+@@ -886,8 +886,11 @@ static int __init test_firmware_init(void)
+ return -ENOMEM;
+
+ rc = __test_firmware_config_init();
+- if (rc)
++ if (rc) {
++ kfree(test_fw_config);
++ pr_err("could not init firmware test config: %d\n", rc);
+ return rc;
++ }
+
+ rc = misc_register(&test_fw_misc_device);
+ if (rc) {
+--
+2.22.0
+
diff --git a/series.conf b/series.conf
index 0b890b99d8..563a54bd7a 100644
--- a/series.conf
+++ b/series.conf
@@ -1130,6 +1130,7 @@
patches.kernel.org/5.2.9-107-scsi-megaraid_sas-fix-panic-on-loading-firmware.patch
patches.kernel.org/5.2.9-108-scsi-ibmvfc-fix-WARN_ON-during-event-pool-relea.patch
patches.kernel.org/5.2.9-109-scsi-scsi_dh_alua-always-use-a-2-second-delay-b.patch
+ patches.kernel.org/5.2.9-110-test_firmware-fix-a-memory-leak-bug.patch
########################################################
# Build fixes that apply to the vanilla kernel too.