]> 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)
commit6e51f7b8086949e17ed9cd858ac16ba458bf40aa
treeec716cb3e3457a639139c31177ab855593366a48
parent08d23ebdcb7819ce967406d85ec88302b069fdef
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: a80da59df198 ("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