Skip to contentSkip to conversation

smb: server: smb2pdu: check return value of xa_store()

PATCH Applied Salah Triki 2 participants 2 messages Apr 16, 2025 – Apr 17, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 smb: server: smb2pdu: check return value of xa_store()

xa_store() may fail so check its return value and return error code if error occurred.

---
Change in v3:
- Replace goto free_chann by kfree(chann) and return xa_err(old).

 fs/smb/server/smb2pdu.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
fs/smb/server/smb2pdu.c +7 -2
index d24d95d15d87..4c3c092d8771 100644
@@ -1445,7 +1445,7 @@ static int ntlm_authenticate(struct ksmbd_work *work,
 {
 	struct ksmbd_conn *conn = work->conn;
 	struct ksmbd_session *sess = work->sess;
-	struct channel *chann = NULL;
+	struct channel *chann = NULL, *old;
 	struct ksmbd_user *user;
 	u64 prev_id;
 	int sz, rc;
@@ -1557,7 +1557,12 @@ static int ntlm_authenticate(struct ksmbd_work *work,
 				return -ENOMEM;
 
 			chann->conn = conn;
-			xa_store(&sess->ksmbd_chann_list, (long)conn, chann, KSMBD_DEFAULT_GFP);
+			old = xa_store(&sess->ksmbd_chann_list, (long)conn, chann,
+					KSMBD_DEFAULT_GFP);
+			if (xa_is_err(old)) {
+				kfree(chann);
+				return xa_err(old);
+			}
 		}
 	}
 
Signature · 1 line
2.43.0
maintainer Applied
#1 lore raw
Quoted 5 lines · Salah Triki

xa_store() may fail so check its return value and return error code if error occurred.

Applied it to #ksmbd-for-next-next.
Thanks!