From: Yang Yingliang <yangyingliang@huawei.com>
To: John Garry <john.garry@huawei.com>,
<linux-kernel@vger.kernel.org>, <linux-scsi@vger.kernel.org>
Cc: <jejb@linux.ibm.com>, <martin.petersen@oracle.com>,
chenxiang <chenxiang66@hisilicon.com>,
"luojiaxing@huawei.com" <luojiaxing@huawei.com>
Subject: Re: [PATCH -next] scsi: hisi_sas: drop free_irq of devm_request_irq allocated irq
Date: Wed, 19 May 2021 11:36:22 +0800 [thread overview]
Message-ID: <30e9c7d4-75c6-8cbc-7a27-d406eae01dad@huawei.com> (raw)
In-Reply-To: <cf6a6fb8-e9e6-967e-a012-8e25a40922ec@huawei.com>
On 2021/5/18 23:34, John Garry wrote:
> On 18/05/2021 14:09, Yang Yingliang wrote:
>> irq allocated with devm_request_irq should not be freed using
>> free_irq, because doing so causes a dangling pointer, and a
>> subsequent double free.
>>
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>> ---
>> drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 6 +++---
>> 1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
>> b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
>> index 499c770d405c..684f762bcfb3 100644
>> --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
>> +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c
>> @@ -4811,9 +4811,9 @@ hisi_sas_v3_destroy_irqs(struct pci_dev *pdev,
>> struct hisi_hba *hisi_hba)
>> {
>> int i;
>> - free_irq(pci_irq_vector(pdev, 1), hisi_hba);
>> - free_irq(pci_irq_vector(pdev, 2), hisi_hba);
>> - free_irq(pci_irq_vector(pdev, 11), hisi_hba);
>> + devm_free_irq(&pdev->dev, pci_irq_vector(pdev, 1), hisi_hba);
>> + devm_free_irq(&pdev->dev, pci_irq_vector(pdev, 2), hisi_hba);
>> + devm_free_irq(&pdev->dev, pci_irq_vector(pdev, 11), hisi_hba);
>> for (i = 0; i < hisi_hba->cq_nvecs; i++) {
>> struct hisi_sas_cq *cq = &hisi_hba->cq[i];
>> int nr = hisi_sas_intr_conv ? 16 : 16 + i;
>>
>
> Does the free_irq(pci_irq_vector(pdev, nr, cq)) call also need to
> change (not shown)?
Yes, I missed that, it should be changed too.
>
> Having said that, why have these at all if we use devm_request_irq()?
> devm_irq_release() calls free_irq().
I keep the original logic here, only avoid double free.
>
> Thanks,
> John
>
> .
next prev parent reply other threads:[~2021-05-19 3:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-18 13:09 Yang Yingliang
2021-05-18 15:34 ` John Garry
2021-05-19 3:36 ` Yang Yingliang [this message]
2021-05-19 11:19 ` John Garry
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=30e9c7d4-75c6-8cbc-7a27-d406eae01dad@huawei.com \
--to=yangyingliang@huawei.com \
--cc=chenxiang66@hisilicon.com \
--cc=jejb@linux.ibm.com \
--cc=john.garry@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=luojiaxing@huawei.com \
--cc=martin.petersen@oracle.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
all inboxes | Powered by JetHome®