提交 bbed8655 编写于 作者: A Arthur Kiyanovski 提交者: Yang Yingliang

net: ena: fix error returning in ena_com_get_hash_function()

[ 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: NSameeh Jubran <sameehj@amazon.com>
Signed-off-by: NArthur Kiyanovski <akiyano@amazon.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 17117fa0
...@@ -2137,6 +2137,9 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev, ...@@ -2137,6 +2137,9 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
rss->hash_key; rss->hash_key;
int rc; int rc;
if (unlikely(!func))
return -EINVAL;
rc = ena_com_get_feature_ex(ena_dev, &get_resp, rc = ena_com_get_feature_ex(ena_dev, &get_resp,
ENA_ADMIN_RSS_HASH_FUNCTION, ENA_ADMIN_RSS_HASH_FUNCTION,
rss->hash_key_dma_addr, rss->hash_key_dma_addr,
...@@ -2149,8 +2152,7 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev, ...@@ -2149,8 +2152,7 @@ int ena_com_get_hash_function(struct ena_com_dev *ena_dev,
if (rss->hash_func) if (rss->hash_func)
rss->hash_func--; rss->hash_func--;
if (func) *func = rss->hash_func;
*func = rss->hash_func;
if (key) if (key)
memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2); memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册