[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1406207604-31653-4-git-send-email-jeffrey.t.kirsher@intel.com>
Date: Thu, 24 Jul 2014 06:13:13 -0700
From: Jeff Kirsher <jeffrey.t.kirsher@...el.com>
To: davem@...emloft.net
Cc: Jacob Keller <jacob.e.keller@...el.com>, netdev@...r.kernel.org,
nhorman@...hat.com, sassmann@...hat.com,
Jeff Kirsher <jeffrey.t.kirsher@...el.com>
Subject: [net-next 03/14] ixgbe: fix use of list_for_each in ixgbe_enumerate_functions
From: Jacob Keller <jacob.e.keller@...el.com>
Fix a bug in the misuse of the list_for_each macro to loop over every
entry in the bus_list. Instead of attempting to loop over the list from
a random entry point, go up to the bus and use the real list_head entry
point. This prevents the possible read or write of unallocated or
incorrectly addressed memory.
Signed-off-by: Jacob Keller <jacob.e.keller@...el.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@...el.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@...el.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 9aa9d0b..4268a89 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7973,23 +7973,20 @@ static const struct net_device_ops ixgbe_netdev_ops = {
**/
static inline int ixgbe_enumerate_functions(struct ixgbe_adapter *adapter)
{
- struct list_head *entry;
+ struct pci_dev *entry;
int physfns = 0;
/* Some cards can not use the generic count PCIe functions method,
* because they are behind a parent switch, so we hardcode these with
* the correct number of functions.
*/
- if (ixgbe_pcie_from_parent(&adapter->hw)) {
+ if (ixgbe_pcie_from_parent(&adapter->hw))
physfns = 4;
- } else {
- list_for_each(entry, &adapter->pdev->bus_list) {
- struct pci_dev *pdev =
- list_entry(entry, struct pci_dev, bus_list);
- /* don't count virtual functions */
- if (!pdev->is_virtfn)
- physfns++;
- }
+
+ list_for_each_entry(entry, &adapter->pdev->bus->devices, bus_list) {
+ /* don't count virtual functions */
+ if (!entry->is_virtfn)
+ physfns++;
}
return physfns;
--
1.9.3
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists