Skip to content

Commit e9a1de3

Browse files
akiyanodavem330
authored andcommitted
net: ena: fix error returning in ena_com_get_hash_function()
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 <[email protected]> Signed-off-by: Arthur Kiyanovski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 80f8443 commit e9a1de3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/ethernet/amazon/ena/ena_com.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2347,6 +2347,9 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
23472347
rss->hash_key;
23482348
int rc;
23492349

2350+
if (unlikely(!func))
2351+
return -EINVAL;
2352+
23502353
rc = ena_com_get_feature_ex(ena_dev, &get_resp,
23512354
ENA_ADMIN_RSS_HASH_FUNCTION,
23522355
rss->hash_key_dma_addr,
@@ -2359,8 +2362,7 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
23592362
if (rss->hash_func)
23602363
rss->hash_func--;
23612364

2362-
if (func)
2363-
*func = rss->hash_func;
2365+
*func = rss->hash_func;
23642366

23652367
if (key)
23662368
memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2);

0 commit comments

Comments
 (0)