[PATCH] comedi: test kmemleak

xiaopeitux@foxmail.com posted 1 patch 9 hours ago
drivers/comedi/comedi_fops.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] comedi: test kmemleak
Posted by xiaopeitux@foxmail.com 9 hours ago
From: Pei Xiao <xiaopei01@kylinos.cn>

#syz test
---
 drivers/comedi/comedi_fops.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/comedi/comedi_fops.c b/drivers/comedi/comedi_fops.c
index 657c98cd723e..283a64613208 100644
--- a/drivers/comedi/comedi_fops.c
+++ b/drivers/comedi/comedi_fops.c
@@ -1935,6 +1935,11 @@ static int do_cmd_ioctl(struct comedi_device *dev,
 		return 0;
 
 cleanup:
+
+	if (async && async->cmd.chanlist) {
+		kfree(async->cmd.chanlist);
+		async->cmd.chanlist = NULL;
+	}
 	do_become_nonbusy(dev, s);
 
 	return ret;
-- 
2.25.1
Re: [syzbot] [comedi?] memory leak in do_cmd_ioctl
Posted by syzbot 8 hours ago
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+f238baf6ded841b5a82e@syzkaller.appspotmail.com
Tested-by: syzbot+f238baf6ded841b5a82e@syzkaller.appspotmail.com

Tested on:

commit:         8f0b4cce Linux 6.19-rc1
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=106c311a580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=d60836e327fd6756
dashboard link: https://syzkaller.appspot.com/bug?extid=f238baf6ded841b5a82e
compiler:       gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=1744cd92580000

Note: testing is done by a robot and is best-effort only.