From: Zhang Shurong Date: Wed, 26 Apr 2023 17:02:20 +0000 (+0800) Subject: wifi: rtw88: fix incorrect error codes in rtw_debugfs_copy_from_user X-Git-Tag: v6.6.7~2536^2~277^2~39 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=225622256b1b7156624e281e1c0251c292ea24cd;p=platform%2Fkernel%2Flinux-starfive.git wifi: rtw88: fix incorrect error codes in rtw_debugfs_copy_from_user If there is a failure during copy_from_user or user-provided data buffer is invalid, rtw_debugfs_copy_from_user should return negative error code instead of a positive value count. Fix this bug by returning correct error code. Moreover, the check of buffer against null is removed since it will be handled by copy_from_user. Signed-off-by: Zhang Shurong Reviewed-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/tencent_D2EB102CC7435C0110154E62ECA6A7D67505@qq.com --- diff --git a/drivers/net/wireless/realtek/rtw88/debug.c b/drivers/net/wireless/realtek/rtw88/debug.c index fa3d73b..3da477e 100644 --- a/drivers/net/wireless/realtek/rtw88/debug.c +++ b/drivers/net/wireless/realtek/rtw88/debug.c @@ -183,8 +183,8 @@ static int rtw_debugfs_copy_from_user(char tmp[], int size, tmp_len = (count > size - 1 ? size - 1 : count); - if (!buffer || copy_from_user(tmp, buffer, tmp_len)) - return count; + if (copy_from_user(tmp, buffer, tmp_len)) + return -EFAULT; tmp[tmp_len] = '\0';