Skip to contentSkip to conversation

qlcnic: off by one in qlcnic_init_pci_info()

PATCH Applied Dan Carpenter 3 participants 3 messages Jun 14, 2012 – Jun 15, 2012

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qlcnic: off by one in qlcnic_init_pci_info()

The adapter->npars[] array has QLCNIC_MAX_PCI_FUNC elements. We allocate it that way a few lines earlier in the function. So this test is off by one.

drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +1 -1
index 33c3e46..212c121 100644
@@ -479,7 +479,7 @@ qlcnic_init_pci_info(struct qlcnic_adapter *adapter)
 
 	for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) {
 		pfn = pci_info[i].id;
-		if (pfn > QLCNIC_MAX_PCI_FUNC) {
+		if (pfn >= QLCNIC_MAX_PCI_FUNC) {
 			ret = QL_STATUS_INVALID_PARAM;
 			goto err_eswitch;
 		}
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Dan Carpenter

The adapter->npars[] array has QLCNIC_MAX_PCI_FUNC elements. We allocate it that way a few lines earlier in the function. So this test is off by one.

drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +0 -0
index 33c3e46..212c121 100644

drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c qlcnic_init_pci_info(struct qlcnic_adapter *adapter) · line 485

Quoted 8 lines
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +1 -1
@@ -479,7 +479,7 @@ qlcnic_init_pci_info(struct qlcnic_adapter *adapter)
 
 	for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) {
 		pfn = pci_info[i].id;
-		if (pfn > QLCNIC_MAX_PCI_FUNC) {
+		if (pfn >= QLCNIC_MAX_PCI_FUNC) {
 			ret = QL_STATUS_INVALID_PARAM;
 			goto err_eswitch;
 		}

Thanks for the patch.