xtensa/simdisk: fix proc_read_simdisk()
authorYi Yang <yiyang13@huawei.com>
Tue, 10 May 2022 08:05:33 +0000 (16:05 +0800)
committerMax Filippov <jcmvbkbc@gmail.com>
Wed, 11 May 2022 09:15:38 +0000 (02:15 -0700)
commitb011946d039d66bbc7102137e98cc67e1356aa87
tree187e0f9ca53b97149bc795bf9945320ade1b1572
parentc6ab42b31fce42c4b7f775752d91db0f2b71c65e
xtensa/simdisk: fix proc_read_simdisk()

The commit a69755b18774 ("xtensa simdisk: switch to proc_create_data()")
split read operation into two parts, first retrieving the path when it's
non-null and second retrieving the trailing '\n'. However when the path
is non-null the first simple_read_from_buffer updates ppos, and the
second simple_read_from_buffer returns 0 if ppos is greater than 1 (i.e.
almost always). As a result reading from that proc file is almost always
empty.

Fix it by making a temporary copy of the path with the trailing '\n' and
using simple_read_from_buffer on that copy.

Cc: stable@vger.kernel.org
Fixes: a69755b18774 ("xtensa simdisk: switch to proc_create_data()")
Signed-off-by: Yi Yang <yiyang13@huawei.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
arch/xtensa/platforms/iss/simdisk.c