]> git.baikalelectronics.ru Git - kernel.git/commit
wifi: rtlwifi: fix error codes in rtl_debugfs_set_write_h2c()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 17 May 2022 11:48:44 +0000 (14:48 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:23:16 +0000 (14:23 +0200)
commitec4059c246d96ac7cb963f061616659969e460b0
treebaf5ab1aee60dc161338e5647861a7820581a846
parentcdd609d06bf155ccc3d781223c0b46ea67aa54fd
wifi: rtlwifi: fix error codes in rtl_debugfs_set_write_h2c()

[ Upstream commit af4635d42499647c990a98fb92d21f6e35253347 ]

If the copy_from_user() fails or the user gives invalid date then the
correct thing to do is to return a negative error code.  (Currently it
returns success).

I made a copy additional related cleanups:
1) There is no need to check "buffer" for NULL.  That's handled by
copy_from_user().
2) The "h2c_len" variable cannot be negative because it is unsigned
and because sscanf() does not return negative error codes.

Fixes: 60701bcdfbec ("rtlwifi: Improve debugging by using debugfs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/YoOLnDkHgVltyXK7@kili
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/realtek/rtlwifi/debug.c