Skip to content

Commit 582c1ae

Browse files
Hao Chenwilldeacon
authored andcommitted
drivers/perf: hisi: hns3: Actually use devm_add_action_or_reset()
pci_alloc_irq_vectors() allocates an irq vector. When devm_add_action() fails, the irq vector is not freed, which leads to a memory leak. Replace the devm_add_action with devm_add_action_or_reset to ensure the irq vector can be destroyed when it fails. Fixes: 66637ab ("drivers/perf: hisi: add driver for HNS3 PMU") Signed-off-by: Hao Chen <[email protected]> Signed-off-by: Junhao He <[email protected]> Reviewed-by: Jijie Shao <[email protected]> Acked-by: Jonathan Cameron <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 81bdd60 commit 582c1ae

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/perf/hisilicon/hns3_pmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ static int hns3_pmu_irq_register(struct pci_dev *pdev,
15281528
return ret;
15291529
}
15301530

1531-
ret = devm_add_action(&pdev->dev, hns3_pmu_free_irq, pdev);
1531+
ret = devm_add_action_or_reset(&pdev->dev, hns3_pmu_free_irq, pdev);
15321532
if (ret) {
15331533
pci_err(pdev, "failed to add free irq action, ret = %d.\n", ret);
15341534
return ret;

0 commit comments

Comments
 (0)