net: netxen: fix a missing check and an uninitialized use
authorKangjie Lu <kjlu@umn.edu>
Fri, 21 Dec 2018 06:22:32 +0000 (00:22 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Jan 2019 09:03:50 +0000 (10:03 +0100)
[ Upstream commit d134e486e831defd26130770181f01dfc6195f7d ]

When netxen_rom_fast_read() fails, "bios" is left uninitialized and may
contain random value, thus should not be used.

The fix ensures that if netxen_rom_fast_read() fails, we return "-EIO".

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/qlogic/netxen/netxen_nic_init.c

index 7b43a3b4abdcbc7bc1cdfd4d13c611563e2760a2..5cf551914767e7de7553039658ac3b7d6267c585 100644 (file)
@@ -1125,7 +1125,8 @@ netxen_validate_firmware(struct netxen_adapter *adapter)
                return -EINVAL;
        }
        val = nx_get_bios_version(adapter);
-       netxen_rom_fast_read(adapter, NX_BIOS_VERSION_OFFSET, (int *)&bios);
+       if (netxen_rom_fast_read(adapter, NX_BIOS_VERSION_OFFSET, (int *)&bios))
+               return -EIO;
        if ((__force u32)val != bios) {
                dev_err(&pdev->dev, "%s: firmware bios is incompatible\n",
                                fw_name[fw_type]);