Re: [EDT] [PATCH] devpts/inode.c : Fix Possible dentry NULL dereference

From: Richard Weinberger
Date: Thu May 21 2015 - 06:42:12 EST


On Thu, May 21, 2015 at 12:28 PM, Maninder Singh
<maninder1.s@xxxxxxxxxxx> wrote:
>
> EP-F6AA0618C49C4AEDA73BFF1B39950BAB

What is this?

> Hi,
>
> Subject: [PATCH 1/1] devpts/inode.c : Fix Possible dentry NULL dereference
>
> Issue reported by static tool Analyzer (Prevent).
> d_find_alias can return NULL to deentry, Thus we need NULL check
> before calling d_delete(dentry)
>
> Signed-off-by: Maninder Singh <maninder1.s@xxxxxxxxxxx>
> Reviewed-by: Vaneet Narang <v.narang@xxxxxxxxxxx>
> ---
> fs/devpts/inode.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
> index add5663..0350ac2 100644
> --- a/fs/devpts/inode.c
> +++ b/fs/devpts/inode.c
> @@ -663,7 +663,8 @@ void devpts_pty_kill(struct inode *inode)
> dentry = d_find_alias(inode);
>
> drop_nlink(inode);
> - d_delete(dentry);
> + if (dentry)
> + d_delete(dentry);
> dput(dentry); /* d_alloc_name() in devpts_pty_new() */
> dput(dentry); /* d_find_alias above */

While it is correct that d_find_alias() may return NULL, can this also
happen here?
I mean if that happens in the kill path we might have bigger trouble...

Al?

--
Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/