diff mbox series

[CIFS] missing null check for newinode pointer

Message ID CAH2r5mtN+0MLW3e_xhqEP3R_EFULWjrzScuyYZgZ2AE9ukERRA@mail.gmail.com
State New
Headers show
Series [CIFS] missing null check for newinode pointer | expand

Commit Message

Steve French June 23, 2021, 1:03 a.m. UTC
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(-)

  d_add(direntry, newinode);

Comments

Sachin Prabhu June 23, 2021, 11:15 a.m. UTC | #1
Acked-by: Sachin Prabhu <sprabhu@redhat.com>

On Wed, Jun 23, 2021 at 2:04 AM Steve French <smfrench@gmail.com> wrote:
>
> 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
diff mbox series

Patch

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