Skip to content

Commit 3abab90

Browse files
Jinjie Ruannamjaejeon
authored andcommitted
ksmbd: Fix the missing xa_store error check
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: [email protected] Fixes: b685757 ("ksmbd: Implements sess->rpc_handle_list as xarray") Signed-off-by: Jinjie Ruan <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 8198375 commit 3abab90

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fs/smb/server/mgmt/user_session.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static int __rpc_method(char *rpc_name)
9090

9191
int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name)
9292
{
93-
struct ksmbd_session_rpc *entry;
93+
struct ksmbd_session_rpc *entry, *old;
9494
struct ksmbd_rpc_command *resp;
9595
int method;
9696

@@ -106,16 +106,19 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name)
106106
entry->id = ksmbd_ipc_id_alloc();
107107
if (entry->id < 0)
108108
goto free_entry;
109-
xa_store(&sess->rpc_handle_list, entry->id, entry, GFP_KERNEL);
109+
old = xa_store(&sess->rpc_handle_list, entry->id, entry, GFP_KERNEL);
110+
if (xa_is_err(old))
111+
goto free_id;
110112

111113
resp = ksmbd_rpc_open(sess, entry->id);
112114
if (!resp)
113-
goto free_id;
115+
goto erase_xa;
114116

115117
kvfree(resp);
116118
return entry->id;
117-
free_id:
119+
erase_xa:
118120
xa_erase(&sess->rpc_handle_list, entry->id);
121+
free_id:
119122
ksmbd_rpc_id_free(entry->id);
120123
free_entry:
121124
kfree(entry);

0 commit comments

Comments
 (0)