Skip to content

Commit

Permalink
i2c: amd-mp2: drop free_irq() of devm_request_irq() allocated irq
Browse files Browse the repository at this point in the history
irq allocated with devm_request_irq() will be freed in devm_irq_release(),
using free_irq() in ->remove() will causes a dangling pointer, and a
subsequent double free. So remove the free_irq() in the error path and
remove path.

Fixes: 969864e ("i2c: amd-mp2: use msix/msi if the hardware supports")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Link: https://lore.kernel.org/r/20221103121146.99836-1-yangyingliang@huawei.com
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
  • Loading branch information
Yang Yingliang authored and Andi Shyti committed Mar 20, 2025
1 parent 4701f33 commit 6ea39cc
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions drivers/i2c/busses/i2c-amd-mp2-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,11 @@ static int amd_mp2_pci_init(struct amd_mp2_dev *privdata,
amd_mp2_irq_isr, irq_flag, dev_name(&pci_dev->dev), privdata);
if (rc) {
pci_err(pci_dev, "Failure requesting irq %i: %d\n", privdata->dev_irq, rc);
goto free_irq_vectors;
goto err_dma_mask;
}

return rc;

free_irq_vectors:
free_irq(privdata->dev_irq, privdata);
err_dma_mask:
pci_clear_master(pci_dev);
err_pci_enable:
Expand Down Expand Up @@ -376,7 +374,6 @@ static void amd_mp2_pci_remove(struct pci_dev *pci_dev)
pm_runtime_forbid(&pci_dev->dev);
pm_runtime_get_noresume(&pci_dev->dev);

free_irq(privdata->dev_irq, privdata);
pci_clear_master(pci_dev);

amd_mp2_clear_reg(privdata);
Expand Down

0 comments on commit 6ea39cc

Please sign in to comment.