[Linux-kernel-mentees] [PATCH] usb: asix: Fix uninit-value in asix_mdio_write

Phong Tran tranmanphong at gmail.com
Thu Nov 7 00:44:04 UTC 2019


The local variables use without initilization value.
This fixes the syzbot report.

Reported-by: syzbot+7dc7c28d4577bbe55b10 at syzkaller.appspotmail.com

Test result:

https://groups.google.com/d/msg/syzkaller-bugs/3H_n05x_sPU/sUoHhxgAAgAJ

Signed-off-by: Phong Tran <tranmanphong at gmail.com>
---
 drivers/net/usb/asix_common.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c
index e39f41efda3e..3c7ccd8a9da8 100644
--- a/drivers/net/usb/asix_common.c
+++ b/drivers/net/usb/asix_common.c
@@ -444,8 +444,8 @@ void asix_set_multicast(struct net_device *net)
 int asix_mdio_read(struct net_device *netdev, int phy_id, int loc)
 {
 	struct usbnet *dev = netdev_priv(netdev);
-	__le16 res;
-	u8 smsr;
+	__le16 res = 0;
+	u8 smsr = 0;
 	int i = 0;
 	int ret;
 
@@ -478,7 +478,7 @@ void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
 {
 	struct usbnet *dev = netdev_priv(netdev);
 	__le16 res = cpu_to_le16(val);
-	u8 smsr;
+	u8 smsr = 0;
 	int i = 0;
 	int ret;
 
@@ -508,8 +508,8 @@ void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val)
 int asix_mdio_read_nopm(struct net_device *netdev, int phy_id, int loc)
 {
 	struct usbnet *dev = netdev_priv(netdev);
-	__le16 res;
-	u8 smsr;
+	__le16 res = 0;
+	u8 smsr = 0;
 	int i = 0;
 	int ret;
 
@@ -543,7 +543,7 @@ asix_mdio_write_nopm(struct net_device *netdev, int phy_id, int loc, int val)
 {
 	struct usbnet *dev = netdev_priv(netdev);
 	__le16 res = cpu_to_le16(val);
-	u8 smsr;
+	u8 smsr = 0;
 	int i = 0;
 	int ret;
 
-- 
2.20.1



More information about the Linux-kernel-mentees mailing list