Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1663067 > unrolled thread

[PATCH] CIFS: Fix some return values in case of error in 'crypt_message'

Started byChristophe JAILLET <christophe.jaillet@wanadoo.fr>
First post2017-06-11 09:20 +0200
Last post2017-06-13 01:20 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] CIFS: Fix some return values in case of error in 'crypt_message' Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-06-11 09:20 +0200
    Re: [PATCH] CIFS: Fix some return values in case of error in 'crypt_message' Aurélien Aptel <aaptel@suse.com> - 2017-06-12 18:20 +0200
    RE: [PATCH] CIFS: Fix some return values in case of error in  'crypt_message' Pavel Shilovskiy <pshilov@microsoft.com> - 2017-06-13 01:20 +0200

#1663067 — [PATCH] CIFS: Fix some return values in case of error in 'crypt_message'

FromChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Date2017-06-11 09:20 +0200
Subject[PATCH] CIFS: Fix some return values in case of error in 'crypt_message'
Message-ID<tR5kd-26K-7@gated-at.bofh.it>
'rc' is known to be 0 at this point. So if 'init_sg' or 'kzalloc' fails, we
should return -ENOMEM instead.

Also remove a useless 'rc' in a debug message as it is meaningless here.

Fixes: 026e93dc0a3ee ("CIFS: Encrypt SMB3 requests before sending")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 fs/cifs/smb2ops.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index c58691834eb2..cdcb3d95add8 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -1809,7 +1809,8 @@ crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc)
 
 	sg = init_sg(rqst, sign);
 	if (!sg) {
-		cifs_dbg(VFS, "%s: Failed to init sg %d", __func__, rc);
+		cifs_dbg(VFS, "%s: Failed to init sg", __func__);
+		rc = -ENOMEM;
 		goto free_req;
 	}
 
@@ -1817,6 +1818,7 @@ crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc)
 	iv = kzalloc(iv_len, GFP_KERNEL);
 	if (!iv) {
 		cifs_dbg(VFS, "%s: Failed to alloc IV", __func__);
+		rc = -ENOMEM;
 		goto free_sg;
 	}
 	iv[0] = 3;
-- 
2.11.0

[toc] | [next] | [standalone]


#1663850

FromAurélien Aptel <aaptel@suse.com>
Date2017-06-12 18:20 +0200
Message-ID<tRAem-4ne-27@gated-at.bofh.it>
In reply to#1663067
Looks good to me.

-- 
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Linux GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)

[toc] | [prev] | [next] | [standalone]


#1664294 — RE: [PATCH] CIFS: Fix some return values in case of error in 'crypt_message'

FromPavel Shilovskiy <pshilov@microsoft.com>
Date2017-06-13 01:20 +0200
SubjectRE: [PATCH] CIFS: Fix some return values in case of error in 'crypt_message'
Message-ID<tRGMO-cb-9@gated-at.bofh.it>
In reply to#1663067
2017-06-11 0:12 GMT-07:00 Christophe JAILLET <christophe.jaillet@wanadoo.fr>:
> 'rc' is known to be 0 at this point. So if 'init_sg' or 'kzalloc' fails, we
> should return -ENOMEM instead.
>
> Also remove a useless 'rc' in a debug message as it is meaningless here.
>
> Fixes: 026e93dc0a3ee ("CIFS: Encrypt SMB3 requests before sending")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  fs/cifs/smb2ops.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> index c58691834eb2..cdcb3d95add8 100644
> --- a/fs/cifs/smb2ops.c
> +++ b/fs/cifs/smb2ops.c
> @@ -1809,7 +1809,8 @@ crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc)
>
>         sg = init_sg(rqst, sign);
>         if (!sg) {
> -               cifs_dbg(VFS, "%s: Failed to init sg %d", __func__, rc);
> +               cifs_dbg(VFS, "%s: Failed to init sg", __func__);
> +               rc = -ENOMEM;
>                 goto free_req;
>         }
>
> @@ -1817,6 +1818,7 @@ crypt_message(struct TCP_Server_Info *server, struct smb_rqst *rqst, int enc)
>         iv = kzalloc(iv_len, GFP_KERNEL);
>         if (!iv) {
>                 cifs_dbg(VFS, "%s: Failed to alloc IV", __func__);
> +               rc = -ENOMEM;
>                 goto free_sg;
>         }
>         iv[0] = 3;
> --
> 2.11.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Thanks for catching this.

Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>

--
Best regards,
Pavel Shilovsky

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web