All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: selftest: Fix memleak in test_ecdh()
@ 2022-11-09  8:58 Chen Zhongjin
  2022-11-09 10:04 ` bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Zhongjin @ 2022-11-09  8:58 UTC (permalink / raw)
  To: linux-kernel, linux-bluetooth, netdev
  Cc: marcel, johan.hedberg, luiz.dentz, davem, edumazet, kuba, pabeni,
	tudor.ambarus, chenzhongjin

kmemleak reported:
 Bluetooth: ECDH sample 1 failed
 kmemleak: 2 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
 unreferenced object 0xffff888102149100 (size 96):
  comm "modprobe", pid 418, jiffies 4295082093 (age 610.644s)
  ...
  backtrace:
    [<00000000c8e4e5a6>] __kmalloc_node+0x4c/0x1c0
    [<000000006cdcfddc>] crypto_create_tfm_node+0x89/0x320
    [<00000000e222ad46>] crypto_alloc_tfm_node+0xfd/0x2f0
    [<00000000871fc045>] 0xffffffffc05c94ab
    [<00000000e889f45e>] 0xffffffffc05c8024
    [<000000001ff0c346>] do_one_initcall+0xd0/0x4e0
  ...

In test_ecdh(), when test sample fails, crypto_free_kpp(tfm) is not
called, which makes tfm memory leaked. Fix it by moving crypto_free_kpp
behind done label.

Fixes: 47eb2ac80918 ("Bluetooth: move ecdh allocation outside of ecdh_helper")
Signed-off-by: Chen Zhongjin <chenzhongjin@huawei.com>
---
 net/bluetooth/selftest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/selftest.c b/net/bluetooth/selftest.c
index f49604d44b87..586125a611dd 100644
--- a/net/bluetooth/selftest.c
+++ b/net/bluetooth/selftest.c
@@ -233,8 +233,6 @@ static int __init test_ecdh(void)
 		goto done;
 	}
 
-	crypto_free_kpp(tfm);
-
 	rettime = ktime_get();
 	delta = ktime_sub(rettime, calltime);
 	duration = (unsigned long long) ktime_to_ns(delta) >> 10;
@@ -248,6 +246,8 @@ static int __init test_ecdh(void)
 	else
 		snprintf(test_ecdh_buffer, sizeof(test_ecdh_buffer), "FAIL\n");
 
+	crypto_free_kpp(tfm);
+
 	debugfs_create_file("selftest_ecdh", 0444, bt_debugfs, NULL,
 			    &test_ecdh_fops);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: Bluetooth: selftest: Fix memleak in test_ecdh()
  2022-11-09  8:58 [PATCH] Bluetooth: selftest: Fix memleak in test_ecdh() Chen Zhongjin
@ 2022-11-09 10:04 ` bluez.test.bot
  0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2022-11-09 10:04 UTC (permalink / raw)
  To: linux-bluetooth, chenzhongjin

[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=693538

---Test result---

Test Summary:
CheckPatch                    PASS      1.59 seconds
GitLint                       PASS      0.98 seconds
SubjectPrefix                 PASS      0.88 seconds
BuildKernel                   PASS      34.37 seconds
BuildKernel32                 PASS      31.17 seconds
Incremental Build with patchesPASS      45.95 seconds
TestRunner: Setup             PASS      520.84 seconds
TestRunner: l2cap-tester      PASS      17.46 seconds
TestRunner: iso-tester        PASS      16.43 seconds
TestRunner: bnep-tester       PASS      6.45 seconds
TestRunner: mgmt-tester       PASS      103.78 seconds
TestRunner: rfcomm-tester     PASS      10.32 seconds
TestRunner: sco-tester        PASS      9.67 seconds
TestRunner: ioctl-tester      PASS      10.73 seconds
TestRunner: mesh-tester       PASS      7.63 seconds
TestRunner: smp-tester        PASS      9.51 seconds
TestRunner: userchan-tester   PASS      6.60 seconds



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-09 10:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09  8:58 [PATCH] Bluetooth: selftest: Fix memleak in test_ecdh() Chen Zhongjin
2022-11-09 10:04 ` bluez.test.bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.