]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: ena: fix error returning in ena_com_get_hash_function()
authorArthur Kiyanovski <akiyano@amazon.com>
Sun, 3 May 2020 09:52:11 +0000 (09:52 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Jun 2020 07:32:19 +0000 (09:32 +0200)
[ Upstream commit e9a1de378dd46375f9abfd8de1e6f59ee114a793 ]

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.

Signed-off-by: Sameeh Jubran <sameehj@amazon.com>
Signed-off-by: Arthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/amazon/ena/ena_com.c

index a250046b8e18632ea5a9b816f726c3bdf52fefb8..07b0f396d3c28a4c1fc7bc4fcd68e2947a56cc82 100644 (file)
@@ -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);