mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/x86/amd: Fix refcount leak in amd_pmc_probe
@ 2022-12-29  7:25 Miaoqian Lin
  2023-01-03  2:00 ` Limonciello, Mario
  2023-01-12 19:05 ` Hans de Goede
  0 siblings, 2 replies; 3+ messages in thread
From: Miaoqian Lin @ 2022-12-29  7:25 UTC (permalink / raw)
  To: Shyam Sundar S K, Hans de Goede, Mark Gross, Sanket Goswami,
	Mario Limonciello, platform-driver-x86, linux-kernel
  Cc: linmq006

pci_get_domain_bus_and_slot() takes reference, the caller should release
the reference by calling pci_dev_put() after use. Call pci_dev_put() in
the error path to fix this.

Fixes: 3d7d407dfb05 ("platform/x86: amd-pmc: Add support for AMD Spill to DRAM STB feature")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/platform/x86/amd/pmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
index 439d282aafd1..8d924986381b 100644
--- a/drivers/platform/x86/amd/pmc.c
+++ b/drivers/platform/x86/amd/pmc.c
@@ -932,7 +932,7 @@ static int amd_pmc_probe(struct platform_device *pdev)
 	if (enable_stb && (dev->cpu_id == AMD_CPU_ID_YC || dev->cpu_id == AMD_CPU_ID_CB)) {
 		err = amd_pmc_s2d_init(dev);
 		if (err)
-			return err;
+			goto err_pci_dev_put;
 	}
 
 	platform_set_drvdata(pdev, dev);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] platform/x86/amd: Fix refcount leak in amd_pmc_probe
  2022-12-29  7:25 [PATCH] platform/x86/amd: Fix refcount leak in amd_pmc_probe Miaoqian Lin
@ 2023-01-03  2:00 ` Limonciello, Mario
  2023-01-12 19:05 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Limonciello, Mario @ 2023-01-03  2:00 UTC (permalink / raw)
  To: Miaoqian Lin, S-k, Shyam-sundar, Hans de Goede, Mark Gross,
	Goswami, Sanket, platform-driver-x86, linux-kernel

[Public]

> -----Original Message-----
> From: Miaoqian Lin <linmq006@gmail.com>
> Sent: Thursday, December 29, 2022 01:26
> To: S-k, Shyam-sundar <Shyam-sundar.S-k@amd.com>; Hans de Goede
> <hdegoede@redhat.com>; Mark Gross <markgross@kernel.org>; Goswami,
> Sanket <Sanket.Goswami@amd.com>; Limonciello, Mario
> <Mario.Limonciello@amd.com>; platform-driver-x86@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Cc: linmq006@gmail.com
> Subject: [PATCH] platform/x86/amd: Fix refcount leak in amd_pmc_probe
> 
> pci_get_domain_bus_and_slot() takes reference, the caller should release
> the reference by calling pci_dev_put() after use. Call pci_dev_put() in
> the error path to fix this.
> 
> Fixes: 3d7d407dfb05 ("platform/x86: amd-pmc: Add support for AMD Spill to
> DRAM STB feature")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

Makes sense to me, thanks!

Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>

> ---
>  drivers/platform/x86/amd/pmc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/amd/pmc.c
> b/drivers/platform/x86/amd/pmc.c
> index 439d282aafd1..8d924986381b 100644
> --- a/drivers/platform/x86/amd/pmc.c
> +++ b/drivers/platform/x86/amd/pmc.c
> @@ -932,7 +932,7 @@ static int amd_pmc_probe(struct platform_device
> *pdev)
>  	if (enable_stb && (dev->cpu_id == AMD_CPU_ID_YC || dev->cpu_id
> == AMD_CPU_ID_CB)) {
>  		err = amd_pmc_s2d_init(dev);
>  		if (err)
> -			return err;
> +			goto err_pci_dev_put;
>  	}
> 
>  	platform_set_drvdata(pdev, dev);
> --
> 2.25.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] platform/x86/amd: Fix refcount leak in amd_pmc_probe
  2022-12-29  7:25 [PATCH] platform/x86/amd: Fix refcount leak in amd_pmc_probe Miaoqian Lin
  2023-01-03  2:00 ` Limonciello, Mario
@ 2023-01-12 19:05 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2023-01-12 19:05 UTC (permalink / raw)
  To: Miaoqian Lin, Shyam Sundar S K, Mark Gross, Sanket Goswami,
	Mario Limonciello, platform-driver-x86, linux-kernel

Hi,

On 12/29/22 08:25, Miaoqian Lin wrote:
> pci_get_domain_bus_and_slot() takes reference, the caller should release
> the reference by calling pci_dev_put() after use. Call pci_dev_put() in
> the error path to fix this.
> 
> Fixes: 3d7d407dfb05 ("platform/x86: amd-pmc: Add support for AMD Spill to DRAM STB feature")
> Signed-off-by: Miaoqian Lin <linmq006@gmail.com>

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

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

I will include this patch in my next fixes pull-req to Linus
for the current kernel development cycle.

Regards,

Hans


> ---
>  drivers/platform/x86/amd/pmc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/amd/pmc.c b/drivers/platform/x86/amd/pmc.c
> index 439d282aafd1..8d924986381b 100644
> --- a/drivers/platform/x86/amd/pmc.c
> +++ b/drivers/platform/x86/amd/pmc.c
> @@ -932,7 +932,7 @@ static int amd_pmc_probe(struct platform_device *pdev)
>  	if (enable_stb && (dev->cpu_id == AMD_CPU_ID_YC || dev->cpu_id == AMD_CPU_ID_CB)) {
>  		err = amd_pmc_s2d_init(dev);
>  		if (err)
> -			return err;
> +			goto err_pci_dev_put;
>  	}
>  
>  	platform_set_drvdata(pdev, dev);


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-12 19:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-29  7:25 [PATCH] platform/x86/amd: Fix refcount leak in amd_pmc_probe Miaoqian Lin
2023-01-03  2:00 ` Limonciello, Mario
2023-01-12 19:05 ` Hans de Goede

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®