Commit 5364ee62 authored by Yi Yang's avatar Yi Yang Committed by Zheng Zengkai
Browse files

xtensa/simdisk: fix proc_read_simdisk()

stable inclusion
from stable-v5.10.121
commit d787a57a17cf0e36cfd44659539c60fa18ce8c9d
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6CQ

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=d787a57a17cf0e36cfd44659539c60fa18ce8c9d



--------------------------------

commit b011946d upstream.

The commit a69755b1 ("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: a69755b1 ("xtensa simdisk: switch to proc_create_data()")
Signed-off-by: default avatarYi Yang <yiyang13@huawei.com>
Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
parent fd210efb
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment