[PATCH 2/2] cifs: check returned value for error

From: Muhammad Usama Anjum
Date: Tue Oct 04 2022 - 02:24:52 EST


smb311_decode_neg_context() can return error. Its return value should be
checked for errors.

Signed-off-by: Muhammad Usama Anjum <usama.anjum@xxxxxxxxxxxxx>
---
fs/cifs/smb2pdu.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 2bf43c892ae6..c6e37352dbe1 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1089,11 +1089,14 @@ SMB2_negotiate(const unsigned int xid,
server->signing_algorithm = SIGNING_ALG_AES_CMAC;
server->signing_negotiated = false;

- if (rsp->NegotiateContextCount)
+ if (rsp->NegotiateContextCount) {
rc = smb311_decode_neg_context(rsp, server,
rsp_iov.iov_len);
- else
+ if (rc)
+ goto neg_exit;
+ } else {
cifs_server_dbg(VFS, "Missing expected negotiate contexts\n");
+ }

/*
* Some servers will not send a SMB2_SIGNING_CAPABILITIES context response (*),
--
2.30.2