]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: usb: dm9601: fix wrong return value in dm9601_mdio_read
authorJavier Carrasco <javier.carrasco.cruz@gmail.com>
Sat, 24 Feb 2024 23:20:06 +0000 (00:20 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Mar 2024 14:48:35 +0000 (14:48 +0000)
commit0ec3ea616a502d508e2f549c48514b3fffbdf63e
tree2dbfe701665bb74a6b5512b5bd5e18224cbb7ced
parent2d8003e55d12c348ea4fbd698944d653dcd33e70
net: usb: dm9601: fix wrong return value in dm9601_mdio_read

[ Upstream commit c68b2c9eba38ec3f60f4894b189090febf4d8d22 ]

The MII code does not check the return value of mdio_read (among
others), and therefore no error code should be sent. A previous fix to
the use of an uninitialized variable propagates negative error codes,
that might lead to wrong operations by the MII library.

An example of such issues is the use of mii_nway_restart by the dm9601
driver. The mii_nway_restart function does not check the value returned
by mdio_read, which in this case might be a negative number which could
contain the exact bit the function checks (BMCR_ANENABLE = 0x1000).

Return zero in case of error, as it is common practice in users of
mdio_read to avoid wrong uses of the return value.

Fixes: 8f8abb863fa5 ("net: usb: dm9601: fix uninitialized variable use in dm9601_mdio_read")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Peter Korsgaard <peter@korsgaard.com>
Link: https://lore.kernel.org/r/20240225-dm9601_ret_err-v1-1-02c1d959ea59@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/usb/dm9601.c