Subject: Re: [net-next 11/14] i40e: handle possible memory allocation failure

From: Sergei Shtylyov <[email-masked]>
Date: Wed, 15 Apr 2015 14:27:56 +0300

Hello.

On 4/15/2015 7:51 AM, Jeff Kirsher wrote:

> From: Jesse Brandeburg <[email-masked]>

> 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 <[email-masked]>
> Tested-by: Jim Young <[email-masked]>
> Signed-off-by: Jeff Kirsher <[email-masked]>
> ---
>   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
[...]
> @@ -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");

    No need for error message, a call trace will be printed on failed 
allocation anyway.

[...]

WBR, Sergei