Message ID | 20200422081628.8103-2-sameehj@amazon.com |
---|---|
State | Changes Requested |
Delegated to: | David Miller |
Headers | show |
Series | Enhance current features in ena driver | expand |
On Wed, 22 Apr 2020 08:16:16 +0000 sameehj@amazon.com wrote: > 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; > + There is a call to this with func being null like 5 lines above: /* Restore the old function */ if (unlikely(rc)) ena_com_get_hash_function(ena_dev, NULL, NULL); What am I missing? > 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);
On Wed, 22 Apr 2020 08:16:16 +0000 sameehj@amazon.com wrote: > 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)") Also, why the fixes tag? Is this a fix for a user-visible problem? > Signed-off-by: Sameeh Jubran <sameehj@amazon.com> > Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
> -----Original Message----- > From: Jakub Kicinski <kuba@kernel.org> > Sent: Thursday, April 23, 2020 3:36 AM > To: Jubran, Samih <sameehj@amazon.com> > Cc: davem@davemloft.net; netdev@vger.kernel.org; Kiyanovski, Arthur > <akiyano@amazon.com>; Woodhouse, David <dwmw@amazon.co.uk>; > Machulsky, Zorik <zorik@amazon.com>; Matushevsky, Alexander > <matua@amazon.com>; Bshara, Saeed <saeedb@amazon.com>; Wilson, > Matt <msw@amazon.com>; Liguori, Anthony <aliguori@amazon.com>; > Bshara, Nafea <nafea@amazon.com>; Tzalik, Guy <gtzalik@amazon.com>; > Belgazal, Netanel <netanel@amazon.com>; Saidi, Ali > <alisaidi@amazon.com>; Herrenschmidt, Benjamin <benh@amazon.com>; > Dagan, Noam <ndagan@amazon.com> > Subject: RE: [EXTERNAL] [PATCH V1 net-next 01/13] net: ena: fix error > returning in ena_com_get_hash_function() > > CAUTION: This email originated from outside of the organization. Do not click > links or open attachments unless you can confirm the sender and know the > content is safe. > > > > On Wed, 22 Apr 2020 08:16:16 +0000 sameehj@amazon.com wrote: > > 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)") > > Also, why the fixes tag? Is this a fix for a user-visible problem? Will drop. > > > Signed-off-by: Sameeh Jubran <sameehj@amazon.com> > > Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
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);