summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorWenwen Wang <wenwen@cs.uga.edu>2019-07-14 01:11:35 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-08-16 10:12:49 +0200
commit0ba69e96cc625786bca775f4e9e8f9d06d512d1a (patch)
tree8b9bd0aa34a0365b4a94c647becc78f3a89e5991 /lib
parentcdd92ebe29c2e36c6b76d0e404ffb6d3d191ec5b (diff)
downloadlinux-stable-0ba69e96cc625786bca775f4e9e8f9d06d512d1a.tar.gz
linux-stable-0ba69e96cc625786bca775f4e9e8f9d06d512d1a.tar.bz2
linux-stable-0ba69e96cc625786bca775f4e9e8f9d06d512d1a.zip
test_firmware: fix a memory leak bug
[ 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>
Diffstat (limited to 'lib')
-rw-r--r--lib/test_firmware.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/test_firmware.c b/lib/test_firmware.c
index fd48a15a0710..a74b1aae7461 100644
--- a/lib/test_firmware.c
+++ b/lib/test_firmware.c
@@ -894,8 +894,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) {