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

Thadeu Lima de Souza Cascardo cascardo at canonical.com
Mon Jul 17 19:29:13 UTC 2017


From: Christophe Jaillet <christophe.jaillet at wanadoo.fr>

BugLink: https://bugs.launchpad.net/bugs/1704857

'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 at wanadoo.fr>
Reviewed-by: Pavel Shilovsky <pshilov at microsoft.com>
Reviewed-by: Aurelien Aptel <aaptel at suse.com>
Signed-off-by: Steve French <smfrench at gmail.com>
CC: Stable <stable at vger.kernel.org>
(cherry picked from commit 517a6e43c4872c89794af5b377fa085e47345952)
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo at canonical.com>
---
 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 b0eb89eddad6..df4274b61ceb 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -1650,7 +1650,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;
 	}
 
@@ -1658,6 +1659,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





More information about the kernel-team mailing list