ksmbd: fix memory leak in smb2_lock()
authorZizhi Wo <wozizhi@huawei.com>
Fri, 1 Dec 2023 14:50:48 +0000 (22:50 +0800)
committerSteve French <stfrench@microsoft.com>
Wed, 6 Dec 2023 02:43:23 +0000 (20:43 -0600)
In smb2_lock(), if setup_async_work() executes successfully,
work->cancel_argv will bind the argv that generated by kmalloc(). And
release_async_work() is called in ksmbd_conn_try_dequeue_request() or
smb2_lock() to release argv.
However, when setup_async_work function fails, work->cancel_argv has not
been bound to the argv, resulting in the previously allocated argv not
being released. Call kfree() to fix it.

Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Signed-off-by: Zizhi Wo <wozizhi@huawei.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/smb2pdu.c

index d369b98a6e10373bbc331beba1daa4414db619a9..bf1dea10c9e77699d6703d7d724a0b6b55d67589 100644 (file)
@@ -7080,6 +7080,7 @@ skip:
                                                      smb2_remove_blocked_lock,
                                                      argv);
                                if (rc) {
+                                       kfree(argv);
                                        err = -ENOMEM;
                                        goto out;
                                }