* [PATCH] befs: fix return value check in befs_iget()
@ 2013-10-29 2:00 Wei Yongjun
2013-10-29 15:09 ` Serge E. Hallyn
2013-10-30 17:52 ` Kees Cook
0 siblings, 2 replies; 4+ messages in thread
From: Wei Yongjun @ 2013-10-29 2:00 UTC (permalink / raw)
To: viro, ebiederm, keescook, serge.hallyn; +Cc: yongjun_wei, linux-kernel
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
In case of error, the function iget_locked() returns NULL pointer
not ERR_PTR(). The IS_ERR() test in the return value check should
be replaced with NULL test.
Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
fs/befs/linuxvfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
index e9c75e2..d714dda 100644
--- a/fs/befs/linuxvfs.c
+++ b/fs/befs/linuxvfs.c
@@ -319,8 +319,8 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
befs_debug(sb, "---> befs_read_inode() " "inode = %lu", ino);
inode = iget_locked(sb, ino);
- if (IS_ERR(inode))
- return inode;
+ if (!inode)
+ return ERR_PTR(-ENOMEM);
if (!(inode->i_state & I_NEW))
return inode;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] befs: fix return value check in befs_iget()
2013-10-29 2:00 [PATCH] befs: fix return value check in befs_iget() Wei Yongjun
@ 2013-10-29 15:09 ` Serge E. Hallyn
2013-10-30 17:52 ` Kees Cook
1 sibling, 0 replies; 4+ messages in thread
From: Serge E. Hallyn @ 2013-10-29 15:09 UTC (permalink / raw)
To: Wei Yongjun
Cc: viro, ebiederm, keescook, serge.hallyn, yongjun_wei, linux-kernel
Quoting Wei Yongjun (weiyj.lk@gmail.com):
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> In case of error, the function iget_locked() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check should
> be replaced with NULL test.
>
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
> ---
> fs/befs/linuxvfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
> index e9c75e2..d714dda 100644
> --- a/fs/befs/linuxvfs.c
> +++ b/fs/befs/linuxvfs.c
> @@ -319,8 +319,8 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
> befs_debug(sb, "---> befs_read_inode() " "inode = %lu", ino);
>
> inode = iget_locked(sb, ino);
> - if (IS_ERR(inode))
> - return inode;
> + if (!inode)
> + return ERR_PTR(-ENOMEM);
> if (!(inode->i_state & I_NEW))
> return inode;
>
>
> --
> 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] 4+ messages in thread
* Re: [PATCH] befs: fix return value check in befs_iget()
2013-10-29 2:00 [PATCH] befs: fix return value check in befs_iget() Wei Yongjun
2013-10-29 15:09 ` Serge E. Hallyn
@ 2013-10-30 17:52 ` Kees Cook
2013-10-30 18:29 ` Dan Carpenter
1 sibling, 1 reply; 4+ messages in thread
From: Kees Cook @ 2013-10-30 17:52 UTC (permalink / raw)
To: Wei Yongjun, Dan Carpenter
Cc: Al Viro, Eric W. Biederman, Serge Hallyn, yongjun_wei, LKML
On Mon, Oct 28, 2013 at 7:00 PM, Wei Yongjun <weiyj.lk@gmail.com> wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> In case of error, the function iget_locked() returns NULL pointer
> not ERR_PTR(). The IS_ERR() test in the return value check should
> be replaced with NULL test.
>
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Good catch, thanks!
Acked-by: Kees Cook <keescook@chromium.org>
As an aside, Dan, how hard would this kind of mismatch be to detect with smatch?
-Kees
> ---
> fs/befs/linuxvfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
> index e9c75e2..d714dda 100644
> --- a/fs/befs/linuxvfs.c
> +++ b/fs/befs/linuxvfs.c
> @@ -319,8 +319,8 @@ static struct inode *befs_iget(struct super_block *sb, unsigned long ino)
> befs_debug(sb, "---> befs_read_inode() " "inode = %lu", ino);
>
> inode = iget_locked(sb, ino);
> - if (IS_ERR(inode))
> - return inode;
> + if (!inode)
> + return ERR_PTR(-ENOMEM);
> if (!(inode->i_state & I_NEW))
> return inode;
>
>
--
Kees Cook
Chrome OS Security
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] befs: fix return value check in befs_iget()
2013-10-30 17:52 ` Kees Cook
@ 2013-10-30 18:29 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2013-10-30 18:29 UTC (permalink / raw)
To: Kees Cook
Cc: Wei Yongjun, Al Viro, Eric W. Biederman, Serge Hallyn, yongjun_wei, LKML
On Wed, Oct 30, 2013 at 10:52:38AM -0700, Kees Cook wrote:
> On Mon, Oct 28, 2013 at 7:00 PM, Wei Yongjun <weiyj.lk@gmail.com> wrote:
> > From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> >
> > In case of error, the function iget_locked() returns NULL pointer
> > not ERR_PTR(). The IS_ERR() test in the return value check should
> > be replaced with NULL test.
> >
> > Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>
> Good catch, thanks!
>
> Acked-by: Kees Cook <keescook@chromium.org>
>
> As an aside, Dan, how hard would this kind of mismatch be to detect
> with smatch?
It already does, but you need the cross function database set up.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-10-30 18:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-29 2:00 [PATCH] befs: fix return value check in befs_iget() Wei Yongjun
2013-10-29 15:09 ` Serge E. Hallyn
2013-10-30 17:52 ` Kees Cook
2013-10-30 18:29 ` Dan Carpenter
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).