From 272eb7b988208c7b9265ea7f2922917e56dc2db5 Mon Sep 17 00:00:00 2001 From: Jingjing Wu Date: Sun, 6 Sep 2015 15:11:39 +0800 Subject: [PATCH] i40e/base: fix error code conversion type The error code sent into i40e_aq_rc_to_posix() are signed values, so we really need to treat them as such. Signed-off-by: Jingjing Wu Acked-by: Helin Zhang Tested-by: Huilong Xu --- drivers/net/i40e/base/i40e_adminq.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/i40e/base/i40e_adminq.h b/drivers/net/i40e/base/i40e_adminq.h index 410d07eed0..7b78b32be8 100644 --- a/drivers/net/i40e/base/i40e_adminq.h +++ b/drivers/net/i40e/base/i40e_adminq.h @@ -115,9 +115,10 @@ struct i40e_adminq_info { /** * i40e_aq_rc_to_posix - convert errors to user-land codes - * aq_rc: AdminQ error code to convert + * aq_ret: AdminQ handler error code can override aq_rc + * aq_rc: AdminQ firmware error code to convert **/ -STATIC inline int i40e_aq_rc_to_posix(int aq_ret, u16 aq_rc) +STATIC inline int i40e_aq_rc_to_posix(int aq_ret, int aq_rc) { int aq_to_posix[] = { 0, /* I40E_AQ_RC_OK */ @@ -149,8 +150,9 @@ STATIC inline int i40e_aq_rc_to_posix(int aq_ret, u16 aq_rc) if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT) return -EAGAIN; - if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))) + if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])))) return -ERANGE; + return aq_to_posix[aq_rc]; } -- 2.20.1