All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Michal Kosiarz <michal.kosiarz@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com, guru.anbalagane@oracle.com,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 20/22] i40e: Fix for division by zero
Date: Mon, 31 Oct 2016 15:29:50 -0700	[thread overview]
Message-ID: <1477952992-125662-21-git-send-email-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <1477952992-125662-1-git-send-email-jeffrey.t.kirsher@intel.com>

From: Michal Kosiarz <michal.kosiarz@intel.com>

For some cases when reading from device are incorrect or image is
incorrect, this part of code causes crash due to division by zero.

Change-ID: I8961029a7a87b0a479995823ef8fcbf6471405e1
Signed-off-by: Michal Kosiarz <michal.kosiarz@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_common.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
index a475946..98791ba 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_common.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
@@ -3313,8 +3313,10 @@ static void i40e_parse_discover_capabilities(struct i40e_hw *hw, void *buff,
 	/* partition id is 1-based, and functions are evenly spread
 	 * across the ports as partitions
 	 */
-	hw->partition_id = (hw->pf_id / hw->num_ports) + 1;
-	hw->num_partitions = num_functions / hw->num_ports;
+	if (hw->num_ports != 0) {
+		hw->partition_id = (hw->pf_id / hw->num_ports) + 1;
+		hw->num_partitions = num_functions / hw->num_ports;
+	}
 
 	/* additional HW specific goodies that might
 	 * someday be HW version specific
-- 
2.7.4

  parent reply	other threads:[~2016-10-31 22:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-31 22:29 [net-next 00/22][pull request] 40GbE Intel Wired LAN Driver Updates 2016-10-31 Jeff Kirsher
2016-10-31 22:29 ` [net-next 01/22] i40e: Add missing \n to end of dev_err message Jeff Kirsher
2016-10-31 22:29 ` [net-next 02/22] i40e: drop is_vf and is_netdev fields in struct i40e_mac_filter Jeff Kirsher
2016-10-31 22:29 ` [net-next 03/22] i40e: make use of __dev_uc_sync and __dev_mc_sync Jeff Kirsher
2016-10-31 22:29 ` [net-next 04/22] i40e: move i40e_put_mac_in_vlan and i40e_del_mac_all_vlan Jeff Kirsher
2016-10-31 22:29 ` [net-next 05/22] i40e: refactor i40e_put_mac_in_vlan to avoid changing f->vlan Jeff Kirsher
2016-10-31 22:29 ` [net-next 06/22] i40e: When searching all MAC/VLAN filters, ignore removed filters Jeff Kirsher
2016-10-31 22:29 ` [net-next 07/22] i40e: implement __i40e_del_filter and use where applicable Jeff Kirsher
2016-10-31 22:29 ` [net-next 08/22] i40e: store MAC/VLAN filters in a hash with the MAC Address as key Jeff Kirsher
2016-10-31 22:29 ` [net-next 09/22] i40e: properly cleanup on allocation failure in i40e_sync_vsi_filters Jeff Kirsher
2016-10-31 22:29 ` [net-next 10/22] i40e: fix MAC filters when removing VLANs Jeff Kirsher
2016-10-31 22:29 ` [net-next 11/22] i40e: avoid looping to check whether we're in VLAN mode Jeff Kirsher
2016-10-31 22:29 ` [net-next 12/22] i40e: remove duplicate add/delete adminq command code for filters Jeff Kirsher
2016-10-31 22:29 ` [net-next 13/22] i40e: correct check for reading TSYNINDX from the receive descriptor Jeff Kirsher
2016-10-31 22:29 ` [net-next 14/22] i40e: use a mutex instead of spinlock in PTP user entry points Jeff Kirsher
2016-10-31 22:29 ` [net-next 15/22] i40e: replace PTP Rx timestamp hang logic Jeff Kirsher
2016-10-31 22:29 ` [net-next 16/22] i40evf: avoid an extra msleep while Jeff Kirsher
2016-10-31 22:29 ` [net-next 17/22] i40e: Add common function for finding VSI by type Jeff Kirsher
2016-10-31 22:29 ` [net-next 18/22] i40e: Reorder logic for coalescing RS bits Jeff Kirsher
2016-10-31 22:29 ` [net-next 19/22] i40e: clear mac filter count on reset Jeff Kirsher
2016-10-31 22:29 ` Jeff Kirsher [this message]
2016-10-31 22:29 ` [net-next 21/22] i40e: Implementation of ERROR state for NVM update state machine Jeff Kirsher
2016-10-31 22:29 ` [net-next 22/22] i40e: removed unreachable code Jeff Kirsher
2016-11-01 14:59 ` [net-next 00/22][pull request] 40GbE Intel Wired LAN Driver Updates 2016-10-31 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1477952992-125662-21-git-send-email-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=davem@davemloft.net \
    --cc=guru.anbalagane@oracle.com \
    --cc=jogreene@redhat.com \
    --cc=michal.kosiarz@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.