Re: [PATCH] zram: fix idle/writeback string compare

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On (03/20/19 08:19), Minchan Kim wrote:
> Cc: <stable@xxxxxxxxxxxxxxx>	[5.0]
> Reported-by: Makoto Wu <makotowu@xxxxxxxxxx>
> Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>

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

> +++ 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



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux