From 43477d2bbf2e0beabce94e6d99ebb5b3c648aaf4 Mon Sep 17 00:00:00 2001 From: Shannon Nelson Date: Thu, 13 Nov 2014 08:23:16 +0000 Subject: [PATCH] i40e: add range check to i40e_aq_rc_to_posix Just to be sure, add a range check to avoid any possible array index-out-of-bound issues. CC: Sergei Shtylyov Change-ID: I9323bee6732c2a47599816e1d6c6b3a1f8dcbf54 Signed-off-by: Shannon Nelson Acked-by: Michal Kosiarz Tested-by: Jim Young Signed-off-by: Jeff Kirsher --- 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 618fe9623b6d..2c68bf7ccd1e 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 >= ARRAY_SIZE(aq_to_posix)) + 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 d5d3c9310d2d..0ffb8d16c63a 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 >= ARRAY_SIZE(aq_to_posix)) + return -ERANGE; return aq_to_posix[aq_rc]; }