diff options
author | Jesse Brandeburg <jesse.brandeburg@intel.com> | 2015-04-07 19:45:39 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2015-04-14 23:32:47 -0400 |
commit | c1147280d2a336ac6723a8dc8b74f809fd6db02c (patch) | |
tree | 56fd0a75dce6caae87f22c84329b5e7499562d6d /drivers/net/ethernet/intel/i40e | |
parent | 73b23402bb232ce655cf45aaca4f7feee317deb1 (diff) |
i40e: handle possible memory allocation failure
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.
Change-ID: I2bf1d826a244209619da4c452d0d58b3eb5e26a3
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Jim Young <james.m.young@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/i40e')
-rw-r--r-- | drivers/net/ethernet/intel/i40e/i40e_main.c | 14 |
1 files 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 63de3f4b7a94..b2972947647e 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: | |||
7301 | * i40e_init_interrupt_scheme - Determine proper interrupt scheme | 7301 | * i40e_init_interrupt_scheme - Determine proper interrupt scheme |
7302 | * @pf: board private structure to initialize | 7302 | * @pf: board private structure to initialize |
7303 | **/ | 7303 | **/ |
7304 | static void i40e_init_interrupt_scheme(struct i40e_pf *pf) | 7304 | static int i40e_init_interrupt_scheme(struct i40e_pf *pf) |
7305 | { | 7305 | { |
7306 | int vectors = 0; | 7306 | int vectors = 0; |
7307 | ssize_t size; | 7307 | ssize_t size; |
@@ -7343,11 +7343,17 @@ static void i40e_init_interrupt_scheme(struct i40e_pf *pf) | |||
7343 | /* set up vector assignment tracking */ | 7343 | /* set up vector assignment tracking */ |
7344 | size = sizeof(struct i40e_lump_tracking) + (sizeof(u16) * vectors); | 7344 | size = sizeof(struct i40e_lump_tracking) + (sizeof(u16) * vectors); |
7345 | pf->irq_pile = kzalloc(size, GFP_KERNEL); | 7345 | pf->irq_pile = kzalloc(size, GFP_KERNEL); |
7346 | if (!pf->irq_pile) { | ||
7347 | dev_err(&pf->pdev->dev, "error allocating irq_pile memory\n"); | ||
7348 | return -ENOMEM; | ||
7349 | } | ||
7346 | pf->irq_pile->num_entries = vectors; | 7350 | pf->irq_pile->num_entries = vectors; |
7347 | pf->irq_pile->search_hint = 0; | 7351 | pf->irq_pile->search_hint = 0; |
7348 | 7352 | ||
7349 | /* track first vector for misc interrupts */ | 7353 | /* track first vector for misc interrupts, ignore return */ |
7350 | (void)i40e_get_lump(pf, pf->irq_pile, 1, I40E_PILE_VALID_BIT - 1); | 7354 | (void)i40e_get_lump(pf, pf->irq_pile, 1, I40E_PILE_VALID_BIT - 1); |
7355 | |||
7356 | return 0; | ||
7351 | } | 7357 | } |
7352 | 7358 | ||
7353 | /** | 7359 | /** |
@@ -9827,7 +9833,9 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
9827 | 9833 | ||
9828 | /* set up the main switch operations */ | 9834 | /* set up the main switch operations */ |
9829 | i40e_determine_queue_usage(pf); | 9835 | i40e_determine_queue_usage(pf); |
9830 | i40e_init_interrupt_scheme(pf); | 9836 | err = i40e_init_interrupt_scheme(pf); |
9837 | if (err) | ||
9838 | goto err_switch_setup; | ||
9831 | 9839 | ||
9832 | /* The number of VSIs reported by the FW is the minimum guaranteed | 9840 | /* The number of VSIs reported by the FW is the minimum guaranteed |
9833 | * to us; HW supports far more and we share the remaining pool with | 9841 | * to us; HW supports far more and we share the remaining pool with |