From: Sachin Prabhu <sprabhu@redhat.com>
To: Steve French <smfrench@gmail.com>
Cc: CIFS <linux-cifs@vger.kernel.org>
Subject: Re: [PATCH][CIFS] missing null check for newinode pointer
Date: Wed, 23 Jun 2021 12:15:39 +0100 [thread overview]
Message-ID: <CAMcOejUBxh3wk6iZyjfbaqPmwSWXWZ7YwYgVTxNyF80Re8pnRw@mail.gmail.com> (raw)
In-Reply-To: <CAH2r5mtN+0MLW3e_xhqEP3R_EFULWjrzScuyYZgZ2AE9ukERRA@mail.gmail.com>
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
prev parent reply other threads:[~2021-06-23 11:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-23 1:03 [PATCH][CIFS] missing null check for newinode pointer Steve French
2021-06-23 11:15 ` Sachin Prabhu [this message]
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=CAMcOejUBxh3wk6iZyjfbaqPmwSWXWZ7YwYgVTxNyF80Re8pnRw@mail.gmail.com \
--to=sprabhu@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=smfrench@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 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).