linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Cc: linux-s390@vger.kernel.org, linux-pci@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linfeilong <linfeilong@huawei.com>,
	gerald.schaefer@linux.ibm.com, bhelgaas@google.com
Subject: Re: [PATCH] pci/hotplug: fix potential memory leak in disable_slot()
Date: Mon, 22 Mar 2021 10:42:33 +0100	[thread overview]
Message-ID: <64ab0093-b4b6-834f-4249-d38e1e1637c0@linux.ibm.com> (raw)
In-Reply-To: <245c1063-f0cf-551a-b93c-1a0a5ac06eff@huawei.com>



On 21/03/2021 16:51, Zhiqiang Liu wrote:
> 
> In disable_slot(), if we obtain desired PCI device
> successfully by calling pci_get_slot(), we should
> call pci_dev_put() to release its reference.

Thanks for the patch! This should however be fixed independently by 
commit 0b13525c20fe ("s390/pci: fix leak of PCI device structure")
which was just added to v5.12-rc4 and will be backported to stable.
There were a few similar cases that also got fixed by that commit.

> 
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> Signed-off-by: Feilong Lin <linfeilong@huawei.com>
> ---
>   drivers/pci/hotplug/s390_pci_hpc.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/s390_pci_hpc.c b/drivers/pci/hotplug/s390_pci_hpc.c
> index c9e790c74051..999a34b6fd50 100644
> --- a/drivers/pci/hotplug/s390_pci_hpc.c
> +++ b/drivers/pci/hotplug/s390_pci_hpc.c
> @@ -89,9 +89,11 @@ static int disable_slot(struct hotplug_slot *hotplug_slot)
>   		return -EIO;
> 
>   	pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);
> -	if (pdev && pci_num_vf(pdev)) {
> +	if (pdev) {
> +		rc = pci_num_vf(pdev);
>   		pci_dev_put(pdev);
> -		return -EBUSY;
> +		if (rc)
> +			return -EBUSY;
>   	}
> 
>   	zpci_remove_device(zdev);
> 

      reply	other threads:[~2021-03-22  9:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-21 15:51 [PATCH] pci/hotplug: fix potential memory leak in disable_slot() Zhiqiang Liu
2021-03-22  9:42 ` Niklas Schnelle [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=64ab0093-b4b6-834f-4249-d38e1e1637c0@linux.ibm.com \
    --to=schnelle@linux.ibm.com \
    --cc=bhelgaas@google.com \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=liuzhiqiang26@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 NNTP newsgroup(s).