Re: [PATCH 1/2] fs: Correctly check d_find_alias() return code indevpts_pty_kill

From: J. Bruce Fields
Date: Fri Feb 04 2011 - 13:11:31 EST


On Fri, Feb 04, 2011 at 06:28:26PM +0300, Andrey Vagin wrote:
> d_find_alias() return NULL in case error, but we expected errno in
> devpts_pty_kill.

Possibly dumb question: can d_find_alias() actually fail here?

--b.

>
> Signed-off-by: Andrey Vagin <avagin@xxxxxxxxxx>
> ---
> fs/devpts/inode.c | 10 ++++------
> 1 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
> index 8392c8c..530b1f1 100644
> --- a/fs/devpts/inode.c
> +++ b/fs/devpts/inode.c
> @@ -544,14 +544,12 @@ void devpts_pty_kill(struct tty_struct *tty)
> mutex_lock(&root->d_inode->i_mutex);
>
> dentry = d_find_alias(inode);
> - if (IS_ERR(dentry))
> + if (!dentry)
> goto out;
>
> - if (dentry) {
> - inode->i_nlink--;
> - d_delete(dentry);
> - dput(dentry); /* d_alloc_name() in devpts_pty_new() */
> - }
> + inode->i_nlink--;
> + d_delete(dentry);
> + dput(dentry); /* d_alloc_name() in devpts_pty_new() */
>
> dput(dentry); /* d_find_alias above */
> out:
> --
> 1.7.2.1
>
> --
> 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/
--
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/