]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit3966cb1e4eb94d0a1ece714c1a8a985cc71a5ee6
treeec716cb3e3457a639139c31177ab855593366a48
parent4782b41264a677207ba75d32ed703e08f7bbd09c
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: 546bcc9de239 ("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