lkml.org 
[lkml]   [2017]   [Dec]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] fs/seq_file: Fix warning of passing zero to 'PTR_ERR'
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 <gomonovych@gmail.com>
> ---
> 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...

\
 
 \ /
  Last update: 2017-12-08 00:24    [W:0.039 / U:1.268 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site