From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: MIME-Version: 1.0 In-Reply-To: <20171207232603.GJ21978@ZenIV.linux.org.uk> References: <1512687788-27172-1-git-send-email-gomonovych@gmail.com> <20171207232326.GI21978@ZenIV.linux.org.uk> <20171207232603.GJ21978@ZenIV.linux.org.uk> From: "Gomonovych, Vasyl" Date: Fri, 8 Dec 2017 08:54:34 +0100 Message-ID: Subject: Re: [PATCH] fs/seq_file: Fix warning of passing zero to 'PTR_ERR' To: Al Viro , willy@infradead.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org List-ID: Hi, Guys sorry for this idiotic piece of code. Yesterday after doc seq_file.txt read I did not catch real way of work ther= e. And made this shit. Sorry. Regards Vasyl On Fri, Dec 8, 2017 at 12:26 AM, Al Viro wrote: > 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 *b= uf, size_t size, loff_t *ppos) >> > size_t offs =3D m->count; >> > loff_t next =3D pos; >> > p =3D m->op->next(m, p, &next); >> > - if (!p || IS_ERR(p)) { >> > - err =3D PTR_ERR(p); >> > + if (IS_ERR(p)) { >> > + err =3D (!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? --=20 =D0=94=D0=BE=D0=B1=D1=80=D0=BE=D1=97 =D0=B2=D0=B0=D0=BC =D0=BF=D0=BE=D1=80= =D0=B8 =D0=B4=D0=BD=D1=8F.