]> www.infradead.org Git - users/jedix/linux-maple.git/commit
i40evf: assign num_active_queues inside i40evf_alloc_queues
authorJacob Keller <jacob.e.keller@intel.com>
Wed, 7 Jun 2017 09:43:01 +0000 (05:43 -0400)
committerJack Vogel <jack.vogel@oracle.com>
Tue, 10 Oct 2017 21:15:24 +0000 (14:15 -0700)
commit0c14605c9abec963e74326efdf715cdb35e294d6
tree7a8611e0c18af19f9dea74eb6cb2fcbdb5172e7c
parent28de6febba890481b79fa32705f23c6f5e6dd448
i40evf: assign num_active_queues inside i40evf_alloc_queues

The variable num_active_queues represents the number of active queues we
have for the device. We assign this pretty early in i40evf_init_subtask.

Several code locations are written with loops over the tx_rings and
rx_rings structures, which don't get allocated until
i40evf_alloc_queues, and which get freed by i40evf_free_queues.

These call sites were written under the assumption that tx_rings and
rx_rings would always be allocated at least when num_active_queues is
non-zero.

Lets fix this by moving the assignment into the function where we
allocate queues. We'll use a temporary variable for storage so that we
don't assign the value in the adapter structure until after the rings
have been set up.

Finally, when we free the queues, we'll clear the value to ensure that
we do not loop over the rings memory that no longer exists.

This resolves a possible NULL pointer dereference in
i40evf_get_ethtool_stats which could occur if the VF fails to recover
from a reset, and then a user requests statistics.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Orabug: 26785018
(cherry picked from commit 65c7006f234c9ede887d468f595f259a5c5cc552)
Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
Reviewed-by: Kyle Fortin <kyle.fortin@oracle.com>
drivers/net/ethernet/intel/i40evf/i40evf_main.c