mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
ksmbd: Fix the missing xa_store error check
commit 3abab905b14f4ba756d413f37f1fb02b708eee93 upstream.
xa_store() can fail, it return xa_err(-EINVAL) if the entry cannot
be stored in an XArray, or xa_err(-ENOMEM) if memory allocation failed,
so check error for xa_store() to fix it.
Cc: stable@vger.kernel.org
Fixes: b685757c7b ("ksmbd: Implements sess->rpc_handle_list as xarray")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
f56446ba53
commit
d8664ce789
@@ -90,7 +90,7 @@ static int __rpc_method(char *rpc_name)
|
|||||||
|
|
||||||
int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name)
|
int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name)
|
||||||
{
|
{
|
||||||
struct ksmbd_session_rpc *entry;
|
struct ksmbd_session_rpc *entry, *old;
|
||||||
struct ksmbd_rpc_command *resp;
|
struct ksmbd_rpc_command *resp;
|
||||||
int method;
|
int method;
|
||||||
|
|
||||||
@@ -106,16 +106,19 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name)
|
|||||||
entry->id = ksmbd_ipc_id_alloc();
|
entry->id = ksmbd_ipc_id_alloc();
|
||||||
if (entry->id < 0)
|
if (entry->id < 0)
|
||||||
goto free_entry;
|
goto free_entry;
|
||||||
xa_store(&sess->rpc_handle_list, entry->id, entry, GFP_KERNEL);
|
old = xa_store(&sess->rpc_handle_list, entry->id, entry, GFP_KERNEL);
|
||||||
|
if (xa_is_err(old))
|
||||||
|
goto free_id;
|
||||||
|
|
||||||
resp = ksmbd_rpc_open(sess, entry->id);
|
resp = ksmbd_rpc_open(sess, entry->id);
|
||||||
if (!resp)
|
if (!resp)
|
||||||
goto free_id;
|
goto erase_xa;
|
||||||
|
|
||||||
kvfree(resp);
|
kvfree(resp);
|
||||||
return entry->id;
|
return entry->id;
|
||||||
free_id:
|
erase_xa:
|
||||||
xa_erase(&sess->rpc_handle_list, entry->id);
|
xa_erase(&sess->rpc_handle_list, entry->id);
|
||||||
|
free_id:
|
||||||
ksmbd_rpc_id_free(entry->id);
|
ksmbd_rpc_id_free(entry->id);
|
||||||
free_entry:
|
free_entry:
|
||||||
kfree(entry);
|
kfree(entry);
|
||||||
|
|||||||
Reference in New Issue
Block a user