lkml.org 
[lkml]   [2018]   [Aug]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] zram: fix bug storing backing_dev
On (08/13/18 15:16), Minchan Kim wrote:
> > The call to strlcpy in backing_dev_store is incorrect. It should take
> > the size of the destination buffer instead of the size of the source
> > buffer. Additionally, ignore the newline character (\n) when reading
> > the new file_name buffer. This makes it possible to set the backing_dev
> > as follows:
> >
> > echo /dev/sdX > /sys/block/zram0/backing_dev
> >
> > Signed-off-by: Peter Kalauskas <peskal@google.com>
> Acked-by: Minchan Kim <minchan@kernel.org>
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
> CC: LKML <linux-kernel@vger.kernel.org>
> Cc: <stable@vger.kernel.org> [4.14+]

Thanks for Cc-ing Minchan.

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

> > - strlcpy(file_name, buf, len);

This is quite interesting. The reason it worked before was the fact that
strlcpy() copies 'len - 1' bytes, which is strlen(buf) - 1 in our case,
so it accidentally didn't copy the trailing new line symbol. Which also
means that "echo -n /dev/sdX" most likely was broken.

-ss

\
 
 \ /
  Last update: 2018-08-13 09:39    [W:0.082 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site