linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][CIFS] missing null check for newinode pointer
@ 2021-06-23  1:03 Steve French
  2021-06-23 11:15 ` Sachin Prabhu
  0 siblings, 1 reply; 2+ messages in thread
From: Steve French @ 2021-06-23  1:03 UTC (permalink / raw)
  To: CIFS

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

in cifs_do_create we check if newinode is valid before referencing it
but are missing the check in one place in fs/cifs/dir.c

Addresses-Coverity: 1357292 ("Dereference after null check")
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/dir.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 912333082b18..aca6ed58cc44 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -384,10 +384,11 @@ cifs_do_create(struct inode *inode, struct
dentry *direntry, unsigned int xid,
  goto out_err;
  }

- if (S_ISDIR(newinode->i_mode)) {
- rc = -EISDIR;
- goto out_err;
- }
+ if (newinode)
+ if (S_ISDIR(newinode->i_mode)) {
+ rc = -EISDIR;
+ goto out_err;
+ }

  d_drop(direntry);
  d_add(direntry, newinode);

-- 
Thanks,

Steve

[-- Attachment #2: 0001-cifs-missing-null-check-for-newinode-pointer.patch --]
[-- Type: text/x-patch, Size: 1017 bytes --]

From 8252c0bc73cad73a8f4f76e90c2381ee34ffbc0f Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Tue, 22 Jun 2021 19:53:08 -0500
Subject: [PATCH] cifs: missing null check for newinode pointer

in cifs_do_create we check if newinode is valid before referencing it
but are missing the check in one place in fs/cifs/dir.c

Addresses-Coverity: 1357292 ("Dereference after null check")
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/dir.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index 912333082b18..aca6ed58cc44 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -384,10 +384,11 @@ cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned int xid,
 		goto out_err;
 	}
 
-	if (S_ISDIR(newinode->i_mode)) {
-		rc = -EISDIR;
-		goto out_err;
-	}
+	if (newinode)
+		if (S_ISDIR(newinode->i_mode)) {
+			rc = -EISDIR;
+			goto out_err;
+		}
 
 	d_drop(direntry);
 	d_add(direntry, newinode);
-- 
2.30.2


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

end of thread, other threads:[~2021-06-23 11:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23  1:03 [PATCH][CIFS] missing null check for newinode pointer Steve French
2021-06-23 11:15 ` Sachin Prabhu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).