linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] fs: Correctly check d_find_alias() return code in devpts_pty_kill
@ 2011-02-04 15:28 Andrey Vagin
  2011-02-04 15:28 ` [PATCH 2/2] fs: devpts_pty_new() return -ENOMEM if dentry allocation failed Andrey Vagin
  2011-02-04 18:11 ` [PATCH 1/2] fs: Correctly check d_find_alias() return code in devpts_pty_kill J. Bruce Fields
  0 siblings, 2 replies; 3+ messages in thread
From: Andrey Vagin @ 2011-02-04 15:28 UTC (permalink / raw)
  To: Al Viro; +Cc: Tejun Heo, Andrew Morton, linux-kernel, Andrey Vagin

d_find_alias() return NULL in case error, but we expected errno in
devpts_pty_kill.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
---
 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


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

* [PATCH 2/2] fs: devpts_pty_new() return -ENOMEM if dentry allocation failed
  2011-02-04 15:28 [PATCH 1/2] fs: Correctly check d_find_alias() return code in devpts_pty_kill Andrey Vagin
@ 2011-02-04 15:28 ` Andrey Vagin
  2011-02-04 18:11 ` [PATCH 1/2] fs: Correctly check d_find_alias() return code in devpts_pty_kill J. Bruce Fields
  1 sibling, 0 replies; 3+ messages in thread
From: Andrey Vagin @ 2011-02-04 15:28 UTC (permalink / raw)
  To: Al Viro; +Cc: Tejun Heo, Andrew Morton, linux-kernel, Andrey Vagin

In this case nobody can open a slave point, so will be better return error
from devpts_pty_new()

Signed-off-by: Andrey Vagin <avagin@openvz.org>
---
 fs/devpts/inode.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index 530b1f1..31474f3 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -479,6 +479,7 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty)
 	struct dentry *root = sb->s_root;
 	struct pts_fs_info *fsi = DEVPTS_SB(sb);
 	struct pts_mount_opts *opts = &fsi->mount_opts;
+	int ret = 0;
 	char s[12];
 
 	/* We're supposed to be given the slave end of a pty */
@@ -504,11 +505,14 @@ int devpts_pty_new(struct inode *ptmx_inode, struct tty_struct *tty)
 	if (dentry) {
 		d_add(dentry, inode);
 		fsnotify_create(root->d_inode, dentry);
+	} else {
+		iput(inode);
+		ret = -ENOMEM;
 	}
 
 	mutex_unlock(&root->d_inode->i_mutex);
 
-	return 0;
+	return ret;
 }
 
 struct tty_struct *devpts_get_tty(struct inode *pts_inode, int number)
-- 
1.7.2.1


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

* Re: [PATCH 1/2] fs: Correctly check d_find_alias() return code in devpts_pty_kill
  2011-02-04 15:28 [PATCH 1/2] fs: Correctly check d_find_alias() return code in devpts_pty_kill Andrey Vagin
  2011-02-04 15:28 ` [PATCH 2/2] fs: devpts_pty_new() return -ENOMEM if dentry allocation failed Andrey Vagin
@ 2011-02-04 18:11 ` J. Bruce Fields
  1 sibling, 0 replies; 3+ messages in thread
From: J. Bruce Fields @ 2011-02-04 18:11 UTC (permalink / raw)
  To: Andrey Vagin; +Cc: Al Viro, Tejun Heo, Andrew Morton, linux-kernel

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@openvz.org>
> ---
>  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@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

end of thread, other threads:[~2011-02-04 18:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-04 15:28 [PATCH 1/2] fs: Correctly check d_find_alias() return code in devpts_pty_kill Andrey Vagin
2011-02-04 15:28 ` [PATCH 2/2] fs: devpts_pty_new() return -ENOMEM if dentry allocation failed Andrey Vagin
2011-02-04 18:11 ` [PATCH 1/2] fs: Correctly check d_find_alias() return code in devpts_pty_kill J. Bruce Fields

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).