Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752149Ab3J3Rwk (ORCPT ); Wed, 30 Oct 2013 13:52:40 -0400 Received: from mail-ob0-f182.google.com ([209.85.214.182]:43271 "EHLO mail-ob0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750719Ab3J3Rwj (ORCPT ); Wed, 30 Oct 2013 13:52:39 -0400 MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 30 Oct 2013 10:52:38 -0700 X-Google-Sender-Auth: vxOIpavRRBoVV8CRuWAqjzznjnk Message-ID: Subject: Re: [PATCH] befs: fix return value check in befs_iget() From: Kees Cook To: Wei Yongjun , Dan Carpenter Cc: Al Viro , "Eric W. Biederman" , Serge Hallyn , yongjun_wei@trendmicro.com.cn, LKML Content-Type: text/plain; charset=ISO-8859-1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1437 Lines: 48 On Mon, Oct 28, 2013 at 7:00 PM, Wei Yongjun wrote: > From: Wei Yongjun > > 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 Good catch, thanks! Acked-by: Kees Cook 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 -- 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/