Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Catherine Sullivan <catherine.sullivan@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [net-next S3 10/13] i40e: handle possible memory allocation failure
Date: Tue,  7 Apr 2015 19:45:39 -0400	[thread overview]
Message-ID: <1428450342-48517-10-git-send-email-catherine.sullivan@intel.com> (raw)
In-Reply-To: <1428450342-48517-1-git-send-email-catherine.sullivan@intel.com>

From: Jesse Brandeburg <jesse.brandeburg@intel.com>

The init_interrupt_scheme function had a possible failure
path to allocate memory that was found by smatch.

This adds the correct handling to the function to abort
probe if the memory allocation fails.

Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Change-ID: I2bf1d826a244209619da4c452d0d58b3eb5e26a3
---
 drivers/net/ethernet/intel/i40e/i40e_main.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 63de3f4..b297294 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -7301,7 +7301,7 @@ err_out:
  * i40e_init_interrupt_scheme - Determine proper interrupt scheme
  * @pf: board private structure to initialize
  **/
-static void i40e_init_interrupt_scheme(struct i40e_pf *pf)
+static int i40e_init_interrupt_scheme(struct i40e_pf *pf)
 {
 	int vectors = 0;
 	ssize_t size;
@@ -7343,11 +7343,17 @@ static void i40e_init_interrupt_scheme(struct i40e_pf *pf)
 	/* set up vector assignment tracking */
 	size = sizeof(struct i40e_lump_tracking) + (sizeof(u16) * vectors);
 	pf->irq_pile = kzalloc(size, GFP_KERNEL);
+	if (!pf->irq_pile) {
+		dev_err(&pf->pdev->dev, "error allocating irq_pile memory\n");
+		return -ENOMEM;
+	}
 	pf->irq_pile->num_entries = vectors;
 	pf->irq_pile->search_hint = 0;
 
-	/* track first vector for misc interrupts */
+	/* track first vector for misc interrupts, ignore return */
 	(void)i40e_get_lump(pf, pf->irq_pile, 1, I40E_PILE_VALID_BIT - 1);
+
+	return 0;
 }
 
 /**
@@ -9827,7 +9833,9 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 	/* set up the main switch operations */
 	i40e_determine_queue_usage(pf);
-	i40e_init_interrupt_scheme(pf);
+	err = i40e_init_interrupt_scheme(pf);
+	if (err)
+		goto err_switch_setup;
 
 	/* The number of VSIs reported by the FW is the minimum guaranteed
 	 * to us; HW supports far more and we share the remaining pool with
-- 
1.9.3


  parent reply	other threads:[~2015-04-07 23:45 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-07 23:45 [Intel-wired-lan] [net-next S3 01/13] i40evf: fix bad indentation Catherine Sullivan
2015-04-07 23:45 ` [Intel-wired-lan] [net-next S3 02/13] i40e: Add support to program FDir SB rules for VF from PF through ethtool Catherine Sullivan
2015-04-07 23:53   ` Jeff Kirsher
2015-04-07 23:45 ` [Intel-wired-lan] [net-next S3 03/13] i40evf: remove aq_pending Catherine Sullivan
2015-04-07 23:53   ` Jeff Kirsher
2015-04-14 15:31     ` Young, James M
2015-04-07 23:45 ` [Intel-wired-lan] [net-next S3 04/13] i40e: notify VFs of link state Catherine Sullivan
2015-04-07 23:53   ` Jeff Kirsher
2015-04-14 15:35     ` Young, James M
2015-04-07 23:45 ` [Intel-wired-lan] [net-next S3 05/13] i40e: move VF notification routines up Catherine Sullivan
2015-04-07 23:54   ` Jeff Kirsher
2015-04-14 15:32     ` Young, James M
2015-04-07 23:45 ` [Intel-wired-lan] [net-next S3 06/13] i40e: For VF reset (VFR and VFLR) add some more delay Catherine Sullivan
2015-04-07 23:54   ` Jeff Kirsher
2015-04-07 23:45 ` [Intel-wired-lan] [net-next S3 07/13] i40e: print FCoE capability reported by the device function Catherine Sullivan
2015-04-07 23:54   ` Jeff Kirsher
2015-04-14 16:40     ` Young, James M
2015-04-07 23:45 ` [Intel-wired-lan] [net-next S3 08/13] i40e: enable user dump of internal hardware state Catherine Sullivan
2015-04-07 23:58   ` Jeff Kirsher
2015-04-14 15:33     ` Young, James M
2015-04-07 23:45 ` [Intel-wired-lan] [net-next S3 09/13] i40e/i40evf: Save WR_CSR_PROT field from DEV/FUNC capabilities Catherine Sullivan
2015-04-07 23:58   ` Jeff Kirsher
2015-04-07 23:45 ` Catherine Sullivan [this message]
2015-04-07 23:58   ` [Intel-wired-lan] [net-next S3 10/13] i40e: handle possible memory allocation failure Jeff Kirsher
2015-04-14 15:36     ` Young, James M
2015-04-07 23:45 ` [Intel-wired-lan] [net-next S3 11/13] i40e: get rid of unused locals Catherine Sullivan
2015-04-07 23:59   ` Jeff Kirsher
2015-04-14 15:34     ` Young, James M
2015-04-07 23:45 ` [Intel-wired-lan] [net-next S3 12/13] i40e: Use new 40G speeds Catherine Sullivan
2015-04-08  0:02   ` Jeff Kirsher
2015-04-14 15:34     ` Young, James M
2015-04-07 23:45 ` [Intel-wired-lan] [net-next S3 13/13] i40e: Bump version to 1.3.2 Catherine Sullivan
2015-04-07 23:59   ` Jeff Kirsher
2015-04-14 15:34     ` Young, James M
2015-04-07 23:52 ` [Intel-wired-lan] [net-next S3 01/13] i40evf: fix bad indentation Jeff Kirsher
2015-04-08  1:37   ` Alexander Duyck
2015-04-08  1:45     ` Jeff Kirsher
2015-04-13 21:10   ` Young, James M

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=1428450342-48517-10-git-send-email-catherine.sullivan@intel.com \
    --to=catherine.sullivan@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox