public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: <sameehj@amazon•com>
To: <davem@davemloft•net>, <netdev@vger•kernel.org>
Cc: Arthur Kiyanovski <akiyano@amazon•com>, <dwmw@amazon•com>,
	<zorik@amazon•com>, <matua@amazon•com>, <saeedb@amazon•com>,
	<msw@amazon•com>, <aliguori@amazon•com>, <nafea@amazon•com>,
	<gtzalik@amazon•com>, <netanel@amazon•com>, <alisaidi@amazon•com>,
	<benh@amazon•com>, <sameehj@amazon•com>, <ndagan@amazon•com>
Subject: [PATCH V1 net-next 01/13] net: ena: fix error returning in ena_com_get_hash_function()
Date: Wed, 22 Apr 2020 08:16:16 +0000	[thread overview]
Message-ID: <20200422081628.8103-2-sameehj@amazon.com> (raw)
In-Reply-To: <20200422081628.8103-1-sameehj@amazon.com>

From: Arthur Kiyanovski <akiyano@amazon•com>

In case the "func" parameter is NULL we now return "-EINVAL".
This shouldn't happen in general, but when it does happen, this is the
proper way to handle it.

We also check func for NULL in the beginning of the function, as there
is no reason to do all the work and realize in the end of the function
it was useless.

Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)")
Signed-off-by: Sameeh Jubran <sameehj@amazon•com>
Signed-off-by: Arthur Kiyanovski <akiyano@amazon•com>
---
 drivers/net/ethernet/amazon/ena/ena_com.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c b/drivers/net/ethernet/amazon/ena/ena_com.c
index a250046b8e18..07b0f396d3c2 100644
--- a/drivers/net/ethernet/amazon/ena/ena_com.c
+++ b/drivers/net/ethernet/amazon/ena/ena_com.c
@@ -2345,6 +2345,9 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
 		rss->hash_key;
 	int rc;
 
+	if (unlikely(!func))
+		return -EINVAL;
+
 	rc = ena_com_get_feature_ex(ena_dev, &get_resp,
 				    ENA_ADMIN_RSS_HASH_FUNCTION,
 				    rss->hash_key_dma_addr,
@@ -2357,8 +2360,7 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
 	if (rss->hash_func)
 		rss->hash_func--;
 
-	if (func)
-		*func = rss->hash_func;
+	*func = rss->hash_func;
 
 	if (key)
 		memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2);
-- 
2.24.1.AMZN


  reply	other threads:[~2020-04-22  8:16 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-22  8:16 [PATCH V1 net-next 00/13] Enhance current features in ena driver sameehj
2020-04-22  8:16 ` sameehj [this message]
2020-04-23  0:34   ` [PATCH V1 net-next 01/13] net: ena: fix error returning in ena_com_get_hash_function() Jakub Kicinski
2020-04-23  0:35   ` Jakub Kicinski
2020-04-26  9:43     ` Jubran, Samih
2020-04-22  8:16 ` [PATCH V1 net-next 02/13] net: ena: avoid unnecessary admin command when RSS function set fails sameehj
2020-04-23  0:39   ` Jakub Kicinski
2020-04-23  0:42     ` Jakub Kicinski
2020-04-26  9:45       ` Jubran, Samih
2020-04-22  8:16 ` [PATCH V1 net-next 03/13] net: ena: allow setting the hash function without changing the key sameehj
2020-04-22  8:16 ` [PATCH V1 net-next 04/13] net: ena: change default RSS hash function to Toeplitz sameehj
2020-04-22  8:16 ` [PATCH V1 net-next 05/13] net: ena: changes to RSS hash key allocation sameehj
2020-04-22  8:16 ` [PATCH V1 net-next 06/13] net: ena: remove code that does nothing sameehj
2020-04-22  8:16 ` [PATCH V1 net-next 07/13] net: ena: add unmask interrupts statistics to ethtool sameehj
2020-04-22  8:16 ` [PATCH V1 net-next 08/13] net: ena: add support for reporting of packet drops sameehj
2020-04-23  0:47   ` Jakub Kicinski
2020-04-28  7:30     ` Jubran, Samih
2020-04-22  8:16 ` [PATCH V1 net-next 09/13] net: ena: implement ena_com_get_admin_polling_mode() sameehj
2020-04-22  8:16 ` [PATCH V1 net-next 10/13] net: ena: use SHUTDOWN as reset reason when closing interface sameehj
2020-04-22  8:16 ` [PATCH V1 net-next 11/13] net: ena: move llq configuration from ena_probe to ena_device_init() sameehj
2020-04-22  8:16 ` [PATCH V1 net-next 12/13] net: ena: cosmetic: remove unnecessary spaces and tabs in ena_com.h macros sameehj
2020-04-22  8:16 ` [PATCH V1 net-next 13/13] net: ena: cosmetic: extract code to ena_indirection_table_set() sameehj

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=20200422081628.8103-2-sameehj@amazon.com \
    --to=sameehj@amazon$(echo .)com \
    --cc=akiyano@amazon$(echo .)com \
    --cc=aliguori@amazon$(echo .)com \
    --cc=alisaidi@amazon$(echo .)com \
    --cc=benh@amazon$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=dwmw@amazon$(echo .)com \
    --cc=gtzalik@amazon$(echo .)com \
    --cc=matua@amazon$(echo .)com \
    --cc=msw@amazon$(echo .)com \
    --cc=nafea@amazon$(echo .)com \
    --cc=ndagan@amazon$(echo .)com \
    --cc=netanel@amazon$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=saeedb@amazon$(echo .)com \
    --cc=zorik@amazon$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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