linux-stable/drivers/block/zram
Peter Kalauskas 256f63f52e drivers/block/zram/zram_drv.c: fix bug storing backing_dev
commit c8bd134a4b upstream.

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

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.

Signed-off-by: Peter Kalauskas <peskal@google.com>
Link: http://lkml.kernel.org/r/20180813061623.GC64836@rodete-desktop-imager.corp.google.com
Acked-by: Minchan Kim <minchan@kernel.org>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: <stable@vger.kernel.org>    [4.14+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-09 19:55:58 +02:00
..
Kconfig License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile zram: delete custom lzo/lz4 2016-07-26 16:19:19 -07:00
zcomp.c zram: use __sysfs_match_string() helper 2017-07-10 16:32:31 -07:00
zcomp.h zram: Convert to hotplug state machine 2016-12-02 00:52:39 +01:00
zram_drv.c drivers/block/zram/zram_drv.c: fix bug storing backing_dev 2018-09-09 19:55:58 +02:00
zram_drv.h zram: write incompressible pages to backing device 2017-09-06 17:27:25 -07:00