[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221116122237.227736-1-xiujianfeng@huawei.com>
Date: Wed, 16 Nov 2022 20:22:37 +0800
From: Xiu Jianfeng <xiujianfeng@...wei.com>
To: <linkinjeon@...nel.org>, <sfrench@...ba.org>,
<senozhatsky@...omium.org>, <tom@...pey.com>, <hyc.lee@...il.com>,
<lsahlber@...hat.com>
CC: <linux-cifs@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH] ksmbd: Fix resource leak in ksmbd_session_rpc_open()
When ksmbd_rpc_open() fails then it must call ksmbd_rpc_id_free() to
undo the result of ksmbd_ipc_id_alloc().
Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Signed-off-by: Xiu Jianfeng <xiujianfeng@...wei.com>
---
fs/ksmbd/mgmt/user_session.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/fs/ksmbd/mgmt/user_session.c b/fs/ksmbd/mgmt/user_session.c
index 3fa2139a0b30..92b1603b5abe 100644
--- a/fs/ksmbd/mgmt/user_session.c
+++ b/fs/ksmbd/mgmt/user_session.c
@@ -108,15 +108,17 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name)
entry->method = method;
entry->id = ksmbd_ipc_id_alloc();
if (entry->id < 0)
- goto error;
+ goto free_entry;
resp = ksmbd_rpc_open(sess, entry->id);
if (!resp)
- goto error;
+ goto free_id;
kvfree(resp);
return entry->id;
-error:
+free_id:
+ ksmbd_rpc_id_free(entry->id);
+free_entry:
list_del(&entry->list);
kfree(entry);
return -EINVAL;
--
2.17.1
Powered by blists - more mailing lists