All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve French <smfrench@gmail.com>
To: ronnie sahlberg <ronniesahlberg@gmail.com>,
	CIFS <linux-cifs@vger.kernel.org>
Subject: [SMB3][PATCHES] two patches for minor coverity warnings
Date: Mon, 23 May 2022 21:00:16 -0500	[thread overview]
Message-ID: <CAH2r5mtJhnTEjv4dHN6Nf+oa1+k+W4hCMk_how3LdH+6BhMmcA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 58 bytes --]

Fixes for two minor Coverity warnings

-- 
Thanks,

Steve

[-- Attachment #2: 0002-smb3-don-t-set-rc-when-used-and-unneeded-in-query_in.patch --]
[-- Type: text/x-patch, Size: 1199 bytes --]

From a6bdf95eeee9c99d6a7b138ab68076ef0f964925 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Mon, 23 May 2022 20:54:04 -0500
Subject: [PATCH 2/2]     smb3: don't set rc when used and unneeded in
 query_info_compound

    rc is not checked so should not be set coming back from open_cached_dir
    (the cfid pointer is checked instead to see if open_cached_dir failed)

    Addresses-Coverity: 1518021 ("Code maintainability issues  (UNUSED_VALUE)")
    Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
    Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/smb2ops.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 0d7feb9e609e..28d1eb7d06e9 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -2700,7 +2700,7 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon,
 	memset(rsp_iov, 0, sizeof(rsp_iov));
 
 	if (!strcmp(path, ""))
-		rc = open_cached_dir(xid, tcon, path, cifs_sb, &cfid);
+		open_cached_dir(xid, tcon, path, cifs_sb, &cfid); /* cfid null if fail to open dir */
 
 	memset(&open_iov, 0, sizeof(open_iov));
 	rqst[0].rq_iov = open_iov;
-- 
2.34.1


[-- Attachment #3: 0001-smb3-check-for-null-tcon.patch --]
[-- Type: text/x-patch, Size: 1401 bytes --]

From bbdf6cf56c88845fb0b713cbf5c6623c53fe40d8 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Mon, 23 May 2022 20:42:03 -0500
Subject: [PATCH 1/2] smb3: check for null tcon

Although unlikely to be null, it is confusing to use a pointer
before checking for it to be null so move the use down after
null check.

Addresses-Coverity: 1517586 ("Null pointer dereferences  (REVERSE_INULL)")
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/smb2ops.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index cbe56ed35694..0d7feb9e609e 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -760,8 +760,8 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
 		struct cifs_sb_info *cifs_sb,
 		struct cached_fid **cfid)
 {
-	struct cifs_ses *ses = tcon->ses;
-	struct TCP_Server_Info *server = ses->server;
+	struct cifs_ses *ses;
+	struct TCP_Server_Info *server;
 	struct cifs_open_parms oparms;
 	struct smb2_create_rsp *o_rsp = NULL;
 	struct smb2_query_info_rsp *qi_rsp = NULL;
@@ -780,6 +780,9 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon,
 	    is_smb1_server(tcon->ses->server))
 		return -ENOTSUPP;
 
+	ses = tcon->ses;
+	server = ses->server;
+
 	if (cifs_sb->root == NULL)
 		return -ENOENT;
 
-- 
2.34.1


             reply	other threads:[~2022-05-24  2:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-24  2:00 Steve French [this message]
2022-05-24  2:01 ` [SMB3][PATCHES] two patches for minor coverity warnings ronnie sahlberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH2r5mtJhnTEjv4dHN6Nf+oa1+k+W4hCMk_how3LdH+6BhMmcA@mail.gmail.com \
    --to=smfrench@gmail.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=ronniesahlberg@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.