linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Pan Bian <bianpan2016@163.com>,
	Shyam Sundar S K <Shyam-sundar.S-k@amd.com>,
	Mark Gross <mgross@linux.intel.com>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] platform/x86: amd-pmc: put device on error paths
Date: Tue, 2 Feb 2021 19:33:19 +0100	[thread overview]
Message-ID: <aed49969-9b6b-c625-9d83-78efbd2276de@redhat.com> (raw)
In-Reply-To: <20210121045005.73342-1-bianpan2016@163.com>

Hi,

On 1/21/21 5:50 AM, Pan Bian wrote:
> Put the PCI device rdev on error paths to fix potential reference count
> leaks.
> 
> Signed-off-by: Pan Bian <bianpan2016@163.com>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans



> ---
>  drivers/platform/x86/amd-pmc.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/platform/x86/amd-pmc.c b/drivers/platform/x86/amd-pmc.c
> index 0102bf1c7916..df140019c4bd 100644
> --- a/drivers/platform/x86/amd-pmc.c
> +++ b/drivers/platform/x86/amd-pmc.c
> @@ -210,31 +210,39 @@ static int amd_pmc_probe(struct platform_device *pdev)
>  	dev->dev = &pdev->dev;
>  
>  	rdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0));
> -	if (!rdev || !pci_match_id(pmc_pci_ids, rdev))
> +	if (!rdev || !pci_match_id(pmc_pci_ids, rdev)) {
> +		pci_dev_put(rdev);
>  		return -ENODEV;
> +	}
>  
>  	dev->cpu_id = rdev->device;
>  	err = pci_write_config_dword(rdev, AMD_PMC_SMU_INDEX_ADDRESS, AMD_PMC_BASE_ADDR_LO);
>  	if (err) {
>  		dev_err(dev->dev, "error writing to 0x%x\n", AMD_PMC_SMU_INDEX_ADDRESS);
> +		pci_dev_put(rdev);
>  		return pcibios_err_to_errno(err);
>  	}
>  
>  	err = pci_read_config_dword(rdev, AMD_PMC_SMU_INDEX_DATA, &val);
> -	if (err)
> +	if (err) {
> +		pci_dev_put(rdev);
>  		return pcibios_err_to_errno(err);
> +	}
>  
>  	base_addr_lo = val & AMD_PMC_BASE_ADDR_HI_MASK;
>  
>  	err = pci_write_config_dword(rdev, AMD_PMC_SMU_INDEX_ADDRESS, AMD_PMC_BASE_ADDR_HI);
>  	if (err) {
>  		dev_err(dev->dev, "error writing to 0x%x\n", AMD_PMC_SMU_INDEX_ADDRESS);
> +		pci_dev_put(rdev);
>  		return pcibios_err_to_errno(err);
>  	}
>  
>  	err = pci_read_config_dword(rdev, AMD_PMC_SMU_INDEX_DATA, &val);
> -	if (err)
> +	if (err) {
> +		pci_dev_put(rdev);
>  		return pcibios_err_to_errno(err);
> +	}
>  
>  	base_addr_hi = val & AMD_PMC_BASE_ADDR_LO_MASK;
>  	pci_dev_put(rdev);
> 


      parent reply	other threads:[~2021-02-02 18:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210121045005.73342-1-bianpan2016@163.com>
2021-01-22  0:04 ` [PATCH] platform/x86: amd-pmc: put device on error paths mark gross
2021-02-02 18:33 ` Hans de Goede [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=aed49969-9b6b-c625-9d83-78efbd2276de@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=bianpan2016@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgross@linux.intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /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).