All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] smb: server: smb2pdu: check return value of xa_store()
@ 2025-04-14 19:24 Salah Triki
  2025-04-15  0:43 ` Namjae Jeon
  0 siblings, 1 reply; 2+ messages in thread
From: Salah Triki @ 2025-04-14 19:24 UTC (permalink / raw)
  To: Namjae Jeon, Steve French, Sergey Senozhatsky, Tom Talpey,
	linux-cifs, linux-kernel
  Cc: salah.triki

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

Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 fs/smb/server/smb2pdu.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index d24d95d15d87..e32f8910e892 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -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,10 @@ 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))
+				return xa_err(old);
 		}
 	}
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] smb: server: smb2pdu: check return value of xa_store()
  2025-04-14 19:24 [PATCH] smb: server: smb2pdu: check return value of xa_store() Salah Triki
@ 2025-04-15  0:43 ` Namjae Jeon
  0 siblings, 0 replies; 2+ messages in thread
From: Namjae Jeon @ 2025-04-15  0:43 UTC (permalink / raw)
  To: Salah Triki
  Cc: Steve French, Sergey Senozhatsky, Tom Talpey, linux-cifs,
	linux-kernel

On Tue, Apr 15, 2025 at 4:25 AM Salah Triki <salah.triki@gmail.com> wrote:
>
> xa_store() may fail so check its return value and return error code if
> error occurred.
>
> Signed-off-by: Salah Triki <salah.triki@gmail.com>
> ---
>  fs/smb/server/smb2pdu.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index d24d95d15d87..e32f8910e892 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -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,10 @@ 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))
We need to free chann before returning the error.
Thanks.
> +                               return xa_err(old);
>                 }
>         }
>
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-15  0:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-14 19:24 [PATCH] smb: server: smb2pdu: check return value of xa_store() Salah Triki
2025-04-15  0:43 ` Namjae Jeon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.