net: asix: fix uninit value bugs
authorPavel Skripkin <paskripkin@gmail.com>
Tue, 17 Aug 2021 16:37:23 +0000 (19:37 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Aug 2021 10:46:52 +0000 (11:46 +0100)
commita786e3195d6af183033e86f0518ffd2c51c0e8ac
treeec716cb3e3457a639139c31177ab855593366a48
parent01634047bf0d5c2d9b7d8095bb4de1663dbeedeb
net: asix: fix uninit value bugs

Syzbot reported uninit-value in asix_mdio_read(). The problem was in
missing error handling. asix_read_cmd() should initialize passed stack
variable smsr, but it can fail in some cases. Then while condidition
checks possibly uninit smsr variable.

Since smsr is uninitialized stack variable, driver can misbehave,
because smsr will be random in case of asix_read_cmd() failure.
Fix it by adding error handling and just continue the loop instead of
checking uninit value.

Added helper function for checking Host_En bit, since wrong loop was used
in 4 functions and there is no need in copy-pasting code parts.

Cc: Robert Foss <robert.foss@collabora.com>
Fixes: d9fe64e51114 ("net: asix: Add in_pm parameter")
Reported-by: syzbot+a631ec9e717fb0423053@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/usb/asix_common.c