Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752335AbdLGX0G (ORCPT ); Thu, 7 Dec 2017 18:26:06 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:38946 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751010AbdLGX0F (ORCPT ); Thu, 7 Dec 2017 18:26:05 -0500 Date: Thu, 7 Dec 2017 23:26:04 +0000 From: Al Viro To: Vasyl Gomonovych Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fs/seq_file: Fix warning of passing zero to 'PTR_ERR' Message-ID: <20171207232603.GJ21978@ZenIV.linux.org.uk> References: <1512687788-27172-1-git-send-email-gomonovych@gmail.com> <20171207232326.GI21978@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171207232326.GI21978@ZenIV.linux.org.uk> User-Agent: Mutt/1.9.0 (2017-09-02) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1064 Lines: 28 On Thu, Dec 07, 2017 at 11:23:26PM +0000, Al Viro wrote: > On Fri, Dec 08, 2017 at 12:03:07AM +0100, Vasyl Gomonovych wrote: > > p could be NULL and passing into PTR_ERR > > > > Signed-off-by: Vasyl Gomonovych > > --- > > fs/seq_file.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/fs/seq_file.c b/fs/seq_file.c > > index 4be761c..8b700b9 100644 > > --- a/fs/seq_file.c > > +++ b/fs/seq_file.c > > @@ -262,8 +262,8 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) > > size_t offs = m->count; > > loff_t next = pos; > > p = m->op->next(m, p, &next); > > - if (!p || IS_ERR(p)) { > > - err = PTR_ERR(p); > > + if (IS_ERR(p)) { > > + err = (!p ? -EFAULT : PTR_ERR(p)); > > What does it fix, if I might ask? And while we are at it, would > you mind explaining the reasoning behind that change? Or, say, > testing done to it... While we are at it, where has that -EFAULT come from? And how would it be ever reached, seeing that IS_ERR(NULL) is false?