From: Andi Shyti <andi.shyti@kernel.org>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: linux-i2c@vger.kernel.org, syniurge@gmail.com,
shyam-sundar.s-k@amd.com, Raju.Rangoju@amd.com,
basavaraj.natikar@amd.com, wsa@kernel.org
Subject: Re: [PATCH -next] i2c: amd-mp2: drop free_irq() of devm_request_irq() allocated irq
Date: Tue, 5 Mar 2024 22:49:11 +0100 [thread overview]
Message-ID: <uensfkhuzcmelmrp52shp64k6k3gzianbhnbppojyenk5enmvs@ljrglx7khzg2> (raw)
In-Reply-To: <20221103121146.99836-1-yangyingliang@huawei.com>
Hi Yang,
long time since this patch has been sent.
On Thu, Nov 03, 2022 at 08:11:46PM +0800, Yang Yingliang wrote:
> 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.
the patch looks correct, but that's not the reason because we
haven't called devm_request_irq() yet.
In theory we shouldn't even need the privdata->dev_irq variable
and we can safely remove it.
In any case, I still would like to have an ack from Elie and
Shyam.
Andi
> Fixes: 969864efae78 ("i2c: amd-mp2: use msix/msi if the hardware supports")
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> drivers/i2c/busses/i2c-amd-mp2-pci.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-amd-mp2-pci.c b/drivers/i2c/busses/i2c-amd-mp2-pci.c
> index 143165300949..ef7370d3dbea 100644
> --- a/drivers/i2c/busses/i2c-amd-mp2-pci.c
> +++ b/drivers/i2c/busses/i2c-amd-mp2-pci.c
> @@ -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:
> @@ -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);
> --
> 2.25.1
>
prev parent reply other threads:[~2024-03-05 21:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-03 12:11 [PATCH -next] i2c: amd-mp2: drop free_irq() of devm_request_irq() allocated irq Yang Yingliang
2023-06-08 20:36 ` Wolfram Sang
2024-03-05 21:49 ` Andi Shyti [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=uensfkhuzcmelmrp52shp64k6k3gzianbhnbppojyenk5enmvs@ljrglx7khzg2 \
--to=andi.shyti@kernel.org \
--cc=Raju.Rangoju@amd.com \
--cc=basavaraj.natikar@amd.com \
--cc=linux-i2c@vger.kernel.org \
--cc=shyam-sundar.s-k@amd.com \
--cc=syniurge@gmail.com \
--cc=wsa@kernel.org \
--cc=yangyingliang@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).