Commit 39ee6e82 authored by Dan Carpenter's avatar Dan Carpenter Committed by David S. Miller

net: hns3: Check for allocation failure

We should return -ENOMEM if the kcalloc() fails.

Fixes: d174ea75 ("net: hns3: add statistics for PFC frames and MAC control frame")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ef76c77a
...@@ -351,6 +351,8 @@ static int hclge_mac_update_stats_complete(struct hclge_dev *hdev, u32 desc_num) ...@@ -351,6 +351,8 @@ static int hclge_mac_update_stats_complete(struct hclge_dev *hdev, u32 desc_num)
int ret; int ret;
desc = kcalloc(desc_num, sizeof(struct hclge_desc), GFP_KERNEL); desc = kcalloc(desc_num, sizeof(struct hclge_desc), GFP_KERNEL);
if (!desc)
return -ENOMEM;
hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_STATS_MAC_ALL, true); hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_STATS_MAC_ALL, true);
ret = hclge_cmd_send(&hdev->hw, desc, desc_num); ret = hclge_cmd_send(&hdev->hw, desc, desc_num);
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment