netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Shannon Nelson <shannon.nelson@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com, Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 03/17] i40e/i40evf: fix up type clash in i40e_aq_rc_to_posix conversion
Date: Wed, 30 Sep 2015 05:52:27 -0700	[thread overview]
Message-ID: <1443617561-40490-4-git-send-email-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <1443617561-40490-1-git-send-email-jeffrey.t.kirsher@intel.com>

From: Shannon Nelson <shannon.nelson@intel.com>

The error code sent into i40e_aq_rc_to_posix() are signed values, so we
really need to treat them as such.

Change-ID: I3d1ae0ee9ae0b1b6f5fc424f8b8cc58b0ea93203
Reported-by: Helin Zhang <helin.zhang@intel.com>
Signed-off-by: Shannon Nelson <shannon.nelson@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_adminq.h   | 9 ++++++---
 drivers/net/ethernet/intel/i40evf/i40e_adminq.h | 9 ++++++---
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq.h b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
index b67b34c..ca81b0b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_adminq.h
+++ b/drivers/net/ethernet/intel/i40e/i40e_adminq.h
@@ -109,9 +109,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(u32 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 */
@@ -143,8 +144,10 @@ static inline int i40e_aq_rc_to_posix(u32 aq_ret, u16 aq_rc)
 	if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
 		return -EAGAIN;
 
-	if (aq_rc >= ARRAY_SIZE(aq_to_posix))
+	if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])) ||
+	    aq_rc < 0)
 		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 547b79b..e62e951 100644
--- a/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
+++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq.h
@@ -109,9 +109,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(u32 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 */
@@ -143,8 +144,10 @@ static inline int i40e_aq_rc_to_posix(u32 aq_ret, u16 aq_rc)
 	if (aq_ret == I40E_ERR_ADMIN_QUEUE_TIMEOUT)
 		return -EAGAIN;
 
-	if (aq_rc >= ARRAY_SIZE(aq_to_posix))
+	if (aq_rc >= (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0])) ||
+	    aq_rc < 0)
 		return -ERANGE;
+
 	return aq_to_posix[aq_rc];
 }
 
-- 
2.4.3

  parent reply	other threads:[~2015-09-30 12:52 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-30 12:52 [net-next 00/17][pull request] Intel Wired LAN Driver Updates 2015-09-30 Jeff Kirsher
2015-09-30 12:52 ` [net-next 01/17] i40evf: missing rtnl_unlock in i40evf_resume() Jeff Kirsher
2015-09-30 12:52 ` [net-next 02/17] i40e: rtnl_lock called twice in i40e_pci_error_resume() Jeff Kirsher
2015-09-30 12:52 ` Jeff Kirsher [this message]
2015-09-30 12:52 ` [net-next 04/17] i40e: Fix a port VLAN configuration bug Jeff Kirsher
2015-09-30 12:52 ` [net-next 05/17] i40e: fixup padding issue in get_cee_dcb_cfg_v1_resp Jeff Kirsher
2015-09-30 12:52 ` [net-next 06/17] i40e/i40evf: fix Tx hang workaround code Jeff Kirsher
2015-09-30 12:52 ` [net-next 07/17] i40e: count drops in netstat interface Jeff Kirsher
2015-09-30 12:52 ` [net-next 08/17] i40e: use QOS field consistently Jeff Kirsher
2015-09-30 12:52 ` [net-next 09/17] i40e: limit debugfs io ops Jeff Kirsher
2015-09-30 12:52 ` [net-next 10/17] i40e: Remove useless message Jeff Kirsher
2015-09-30 12:52 ` [net-next 11/17] i40e/i40evf: add new device id 1588 Jeff Kirsher
2015-09-30 12:52 ` [net-next 12/17] i40e: Strip VEB stats if they are disabled in HW Jeff Kirsher
2015-09-30 12:52 ` [net-next 13/17] i40e: refactor interrupt enable Jeff Kirsher
2015-09-30 12:52 ` [net-next 14/17] i40e: warn on double free Jeff Kirsher
2015-09-30 12:52 ` [net-next 15/17] i40evf: tweak init timing Jeff Kirsher
2015-09-30 12:52 ` [net-next 16/17] i40e: fix kbuild warnings Jeff Kirsher
2015-09-30 12:52 ` [net-next 17/17] i40e: fix 32 bit build warnings Jeff Kirsher
2015-10-03 12:17 ` [net-next 00/17][pull request] Intel Wired LAN Driver Updates 2015-09-30 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1443617561-40490-4-git-send-email-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=davem@davemloft.net \
    --cc=jogreene@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.com \
    --cc=shannon.nelson@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).