Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netxen: Error return off by one for XG port.

There are NETXEN_NIU_MAX_XG_PORTS ports.
Port indexing starts from zero.
Hence we should also return error for 'port == NETXEN_NIU_MAX_XG_PORTS'.

Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>

authored by

Santosh Nayak and committed by
David S. Miller
ed3b856b d8140b2f

+4 -4
+2 -2
drivers/net/ethernet/qlogic/netxen/netxen_nic_ethtool.c
··· 511 511 break; 512 512 } 513 513 } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { 514 - if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) 514 + if ((port < 0) || (port >= NETXEN_NIU_MAX_XG_PORTS)) 515 515 return; 516 516 pause->rx_pause = 1; 517 517 val = NXRD32(adapter, NETXEN_NIU_XG_PAUSE_CTL); ··· 577 577 } 578 578 NXWR32(adapter, NETXEN_NIU_GB_PAUSE_CTL, val); 579 579 } else if (adapter->ahw.port_type == NETXEN_NIC_XGBE) { 580 - if ((port < 0) || (port > NETXEN_NIU_MAX_XG_PORTS)) 580 + if ((port < 0) || (port >= NETXEN_NIU_MAX_XG_PORTS)) 581 581 return -EIO; 582 582 val = NXRD32(adapter, NETXEN_NIU_XG_PAUSE_CTL); 583 583 if (port == 0) {
+2 -2
drivers/net/ethernet/qlogic/netxen/netxen_nic_hw.c
··· 365 365 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) 366 366 return 0; 367 367 368 - if (port > NETXEN_NIU_MAX_XG_PORTS) 368 + if (port >= NETXEN_NIU_MAX_XG_PORTS) 369 369 return -EINVAL; 370 370 371 371 mac_cfg = 0; ··· 392 392 u32 port = adapter->physical_port; 393 393 u16 board_type = adapter->ahw.board_type; 394 394 395 - if (port > NETXEN_NIU_MAX_XG_PORTS) 395 + if (port >= NETXEN_NIU_MAX_XG_PORTS) 396 396 return -EINVAL; 397 397 398 398 mac_cfg = NXRD32(adapter, NETXEN_NIU_XGE_CONFIG_0 + (0x10000 * port));