* [PATCH] fs: uselib - Set error on do_filp_open failure only
@ 2012-04-21 21:49 Sasikanth V
2012-04-21 22:00 ` Jesper Juhl
2012-04-21 22:09 ` Al Viro
0 siblings, 2 replies; 3+ messages in thread
From: Sasikanth V @ 2012-04-21 21:49 UTC (permalink / raw)
To: Alexander Viro; +Cc: linux-fsdevel, linux-kernel, Sasikanth V
At present "error" is set irrespective of do_filp_open failed or not.
Setting error to PTR_ERR(file) on do_filp_open failure only.
Signed-off-by: Sasikanth V <sasikanth.v19@gmail.com>
---
fs/exec.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/exec.c b/fs/exec.c
index b1fd202..cb43367 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -129,9 +129,10 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
file = do_filp_open(AT_FDCWD, tmp, &uselib_flags, LOOKUP_FOLLOW);
putname(tmp);
- error = PTR_ERR(file);
- if (IS_ERR(file))
+ if (IS_ERR(file)) {
+ error = PTR_ERR(file);
goto out;
+ }
error = -EINVAL;
if (!S_ISREG(file->f_path.dentry->d_inode->i_mode))
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fs: uselib - Set error on do_filp_open failure only
2012-04-21 21:49 [PATCH] fs: uselib - Set error on do_filp_open failure only Sasikanth V
@ 2012-04-21 22:00 ` Jesper Juhl
2012-04-21 22:09 ` Al Viro
1 sibling, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2012-04-21 22:00 UTC (permalink / raw)
To: Sasikanth V; +Cc: Alexander Viro, linux-fsdevel, linux-kernel
On Sun, 22 Apr 2012, Sasikanth V wrote:
> At present "error" is set irrespective of do_filp_open failed or not.
> Setting error to PTR_ERR(file) on do_filp_open failure only.
>
> Signed-off-by: Sasikanth V <sasikanth.v19@gmail.com>
> ---
> fs/exec.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/exec.c b/fs/exec.c
> index b1fd202..cb43367 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -129,9 +129,10 @@ SYSCALL_DEFINE1(uselib, const char __user *, library)
>
> file = do_filp_open(AT_FDCWD, tmp, &uselib_flags, LOOKUP_FOLLOW);
> putname(tmp);
> - error = PTR_ERR(file);
> - if (IS_ERR(file))
> + if (IS_ERR(file)) {
> + error = PTR_ERR(file);
> goto out;
> + }
> error = -EINVAL;
> if (!S_ISREG(file->f_path.dentry->d_inode->i_mode))
>
Ok, maybe I'm just stupid, but I really don't see the point of this patch.
With the original code, if "IS_ERR(file)" is true we'll "goto out" with
'error' set to 'PTR_ERR(file)' and if it is false we'll set 'error =
-EINVAL' and continue on...
With your new version we will, as I read the code, "goto out" with "error
= PTR_ERR(file)" if "IS_ERR(file)" is true and if it is false we'll set
'error = -EINVAL' and continue.
As I see it, there's no difference, except that your new version adds one
extra line to the source file.
Am I missing something (as in "being completely braindead") or??
--
Jesper Juhl <jj@chaosbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs: uselib - Set error on do_filp_open failure only
2012-04-21 21:49 [PATCH] fs: uselib - Set error on do_filp_open failure only Sasikanth V
2012-04-21 22:00 ` Jesper Juhl
@ 2012-04-21 22:09 ` Al Viro
1 sibling, 0 replies; 3+ messages in thread
From: Al Viro @ 2012-04-21 22:09 UTC (permalink / raw)
To: Sasikanth V; +Cc: linux-fsdevel, linux-kernel
On Sun, Apr 22, 2012 at 03:19:43AM +0530, Sasikanth V wrote:
> At present "error" is set irrespective of do_filp_open failed or not.
> Setting error to PTR_ERR(file) on do_filp_open failure only.
NAK, since it's completely pointless. PTR_ERR() is safe to use on *any*
pointers; result won't be anything interesting unless IS_ERR() is true,
but PTR_ERR() itself can be evaluated just fine.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-04-21 22:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-21 21:49 [PATCH] fs: uselib - Set error on do_filp_open failure only Sasikanth V
2012-04-21 22:00 ` Jesper Juhl
2012-04-21 22:09 ` Al Viro
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).