[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <548705FC.6020805@cogentembedded.com>
Date: Tue, 09 Dec 2014 17:23:56 +0300
From: Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To: Jeff Kirsher <jeffrey.t.kirsher@...el.com>, davem@...emloft.net
CC: Shannon Nelson <shannon.nelson@...el.com>, netdev@...r.kernel.org,
nhorman@...hat.com, sassmann@...hat.com, jogreene@...hat.com
Subject: Re: [net-next 05/13] i40e: add range check to i40e_aq_rc_to_posix
Hello.
On 12/9/2014 2:22 PM, Jeff Kirsher wrote:
> From: Shannon Nelson <shannon.nelson@...el.com>
> Just to be sure, add a range check to avoid any possible
> array index-out-of-bound issues.
> Change-ID: I9323bee6732c2a47599816e1d6c6b3a1f8dcbf54
> Signed-off-by: Shannon Nelson <shannon.nelson@...el.com>
> Acked-by: Michal Kosiarz <michal.kosiarz@...el.com>
> Tested-by: Jim Young <jamesx.m.young@...el.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@...el.com>
> ---
> drivers/net/ethernet/intel/i40e/i40e_adminq.h | 2 ++
> drivers/net/ethernet/intel/i40evf/i40e_adminq.h | 2 ++
> 2 files changed, 4 insertions(+)
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.h b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
> index 618fe96..4064b1e 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_adminq.h
> +++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
> @@ -136,6 +136,8 @@ static inline int i40e_aq_rc_to_posix(u16 aq_rc)
> -EFBIG, /* I40E_AQ_RC_EFBIG */
> };
>
> + if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))
There's ARRAY_SIZE() macro exactly for such computations. And parens
around the last 'aq_to_posix' are not needed.
> + return -ERANGE;
> return aq_to_posix[aq_rc];
> }
>
> diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
> index d5d3c93..4d63514 100644
> --- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
> +++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
> @@ -136,6 +136,8 @@ static inline int i40e_aq_rc_to_posix(u16 aq_rc)
> -EFBIG, /* I40E_AQ_RC_EFBIG */
> };
>
> + if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))
Likewise.
[...]
WBR, Sergei
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists