Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f09ba3e authored by Peter Kalauskas's avatar Peter Kalauskas
Browse files

UPSTREAM: drivers/block/zram/zram_drv.c: fix bug storing backing_dev



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: default avatarPeter Kalauskas <peskal@google.com>
Link: http://lkml.kernel.org/r/20180813061623.GC64836@rodete-desktop-imager.corp.google.com


Acked-by: default avatarMinchan Kim <minchan@kernel.org>
Reviewed-by: default avatarSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: <stable@vger.kernel.org>    [4.14+]
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit c8bd134a4bddafe5917d163eea73873932c15e83)
Signed-off-by: default avatarPeter Kalauskas <peskal@google.com>
Bug: 112488418
Change-Id: I95e90c5b19981d443669a03de59821fb64b9c0ce
parent 89d3f7ee
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment