lkml.org 
[lkml]   [2019]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] zram: fix idle/writeback string compare
On (03/20/19 08:19), Minchan Kim wrote:
> Cc: <stable@vger.kernel.org> [5.0]
> Reported-by: Makoto Wu <makotowu@google.com>
> Signed-off-by: Minchan Kim <minchan@kernel.org>

Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

> +++ b/drivers/block/zram/zram_drv.c
> @@ -290,18 +290,8 @@ static ssize_t idle_store(struct device *dev,
> struct zram *zram = dev_to_zram(dev);
> unsigned long nr_pages = zram->disksize >> PAGE_SHIFT;
> int index;
> - char mode_buf[8];
> - ssize_t sz;
>
> - sz = strscpy(mode_buf, buf, sizeof(mode_buf));
> - if (sz <= 0)
> - return -EINVAL;
> -
> - /* ignore trailing new line */
> - if (mode_buf[sz - 1] == '\n')
> - mode_buf[sz - 1] = 0x00;
> -
> - if (strcmp(mode_buf, "all"))
> + if (!sysfs_streq(buf, "all"))
> return -EINVAL;
[..]

That's a good improvement of the code.

-ss

\
 
 \ /
  Last update: 2019-03-20 02:55    [W:0.033 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site