Skip to content

Commit c2a1626

Browse files
IronShenPaolo Abeni
authored andcommitted
net: hns3: using the num_tqps in the vf driver to apply for resources
Currently, hdev->htqp is allocated using hdev->num_tqps, and kinfo->tqp is allocated using kinfo->num_tqps. However, kinfo->num_tqps is set to min(new_tqps, hdev->num_tqps); Therefore, kinfo->num_tqps may be smaller than hdev->num_tqps, which causes some hdev->htqp[i] to remain uninitialized in hclgevf_knic_setup(). Thus, this patch allocates hdev->htqp and kinfo->tqp using hdev->num_tqps, ensuring that the lengths of hdev->htqp and kinfo->tqp are consistent and that all elements are properly initialized. Fixes: e2cb1de ("net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support") Signed-off-by: Jian Shen <shenjian15@huawei.com> Signed-off-by: Jijie Shao <shaojijie@huawei.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20251211023737.2327018-2-shaojijie@huawei.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 2939203 commit c2a1626

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,12 @@ static int hclgevf_knic_setup(struct hclgevf_dev *hdev)
368368
new_tqps = kinfo->rss_size * num_tc;
369369
kinfo->num_tqps = min(new_tqps, hdev->num_tqps);
370370

371-
kinfo->tqp = devm_kcalloc(&hdev->pdev->dev, kinfo->num_tqps,
371+
kinfo->tqp = devm_kcalloc(&hdev->pdev->dev, hdev->num_tqps,
372372
sizeof(struct hnae3_queue *), GFP_KERNEL);
373373
if (!kinfo->tqp)
374374
return -ENOMEM;
375375

376-
for (i = 0; i < kinfo->num_tqps; i++) {
376+
for (i = 0; i < hdev->num_tqps; i++) {
377377
hdev->htqp[i].q.handle = &hdev->nic;
378378
hdev->htqp[i].q.tqp_index = i;
379379
kinfo->tqp[i] = &hdev->htqp[i].q;

0 commit comments

Comments
 (0)