* [PATCH] platform/x86: intel_pmc_core: fix memleak on registration failure
@ 2021-12-22 10:50 Johan Hovold
2021-12-22 11:05 ` Greg Kroah-Hartman
2021-12-23 18:47 ` Hans de Goede
0 siblings, 2 replies; 4+ messages in thread
From: Johan Hovold @ 2021-12-22 10:50 UTC (permalink / raw)
To: Rajneesh Bhardwaj, David E Box
Cc: Hans de Goede, Mark Gross, Greg Kroah-Hartman,
platform-driver-x86, linux-kernel, Johan Hovold, stable
In case device registration fails during module initialisation, the
platform device structure needs to be freed using platform_device_put()
to properly free all resources (e.g. the device name).
Fixes: 938835aa903a ("platform/x86: intel_pmc_core: do not create a static struct device")
Cc: stable@vger.kernel.org # 5.9
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/platform/x86/intel/pmc/pltdrv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/x86/intel/pmc/pltdrv.c b/drivers/platform/x86/intel/pmc/pltdrv.c
index 73797680b895..15ca8afdd973 100644
--- a/drivers/platform/x86/intel/pmc/pltdrv.c
+++ b/drivers/platform/x86/intel/pmc/pltdrv.c
@@ -65,7 +65,7 @@ static int __init pmc_core_platform_init(void)
retval = platform_device_register(pmc_core_device);
if (retval)
- kfree(pmc_core_device);
+ platform_device_put(pmc_core_device);
return retval;
}
--
2.32.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] platform/x86: intel_pmc_core: fix memleak on registration failure
2021-12-22 10:50 [PATCH] platform/x86: intel_pmc_core: fix memleak on registration failure Johan Hovold
@ 2021-12-22 11:05 ` Greg Kroah-Hartman
2021-12-23 18:47 ` Hans de Goede
1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2021-12-22 11:05 UTC (permalink / raw)
To: Johan Hovold
Cc: Rajneesh Bhardwaj, David E Box, Hans de Goede, Mark Gross,
platform-driver-x86, linux-kernel, stable
On Wed, Dec 22, 2021 at 11:50:23AM +0100, Johan Hovold wrote:
> In case device registration fails during module initialisation, the
> platform device structure needs to be freed using platform_device_put()
> to properly free all resources (e.g. the device name).
>
> Fixes: 938835aa903a ("platform/x86: intel_pmc_core: do not create a static struct device")
> Cc: stable@vger.kernel.org # 5.9
> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
> drivers/platform/x86/intel/pmc/pltdrv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/intel/pmc/pltdrv.c b/drivers/platform/x86/intel/pmc/pltdrv.c
> index 73797680b895..15ca8afdd973 100644
> --- a/drivers/platform/x86/intel/pmc/pltdrv.c
> +++ b/drivers/platform/x86/intel/pmc/pltdrv.c
> @@ -65,7 +65,7 @@ static int __init pmc_core_platform_init(void)
>
> retval = platform_device_register(pmc_core_device);
> if (retval)
> - kfree(pmc_core_device);
> + platform_device_put(pmc_core_device);
>
> return retval;
> }
> --
> 2.32.0
>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] platform/x86: intel_pmc_core: fix memleak on registration failure
2021-12-22 10:50 [PATCH] platform/x86: intel_pmc_core: fix memleak on registration failure Johan Hovold
2021-12-22 11:05 ` Greg Kroah-Hartman
@ 2021-12-23 18:47 ` Hans de Goede
1 sibling, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2021-12-23 18:47 UTC (permalink / raw)
To: Johan Hovold, Rajneesh Bhardwaj, David E Box
Cc: Mark Gross, Greg Kroah-Hartman, platform-driver-x86,
linux-kernel, stable
Hi,
On 12/22/21 11:50, Johan Hovold wrote:
> In case device registration fails during module initialisation, the
> platform device structure needs to be freed using platform_device_put()
> to properly free all resources (e.g. the device name).
>
> Fixes: 938835aa903a ("platform/x86: intel_pmc_core: do not create a static struct device")
> Cc: stable@vger.kernel.org # 5.9
> Signed-off-by: Johan Hovold <johan@kernel.org>
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/intel/pmc/pltdrv.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/intel/pmc/pltdrv.c b/drivers/platform/x86/intel/pmc/pltdrv.c
> index 73797680b895..15ca8afdd973 100644
> --- a/drivers/platform/x86/intel/pmc/pltdrv.c
> +++ b/drivers/platform/x86/intel/pmc/pltdrv.c
> @@ -65,7 +65,7 @@ static int __init pmc_core_platform_init(void)
>
> retval = platform_device_register(pmc_core_device);
> if (retval)
> - kfree(pmc_core_device);
> + platform_device_put(pmc_core_device);
>
> return retval;
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] platform/x86: intel_pmc_core: fix memleak on registration failure
@ 2021-12-25 10:28 Simon Bursten
0 siblings, 0 replies; 4+ messages in thread
From: Simon Bursten @ 2021-12-25 10:28 UTC (permalink / raw)
To: smnbursten; +Cc: Johan Hovold, stable, Greg Kroah-Hartman, Hans de Goede
From: Johan Hovold <johan@kernel.org>
In case device registration fails during module initialisation, the
platform device structure needs to be freed using platform_device_put()
to properly free all resources (e.g. the device name).
Fixes: 938835aa903a ("platform/x86: intel_pmc_core: do not create a static struct device")
Cc: stable@vger.kernel.org # 5.9
Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/r/20211222105023.6205-1-johan@kernel.org
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/platform/x86/intel/pmc/pltdrv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/x86/intel/pmc/pltdrv.c b/drivers/platform/x86/intel/pmc/pltdrv.c
index 73797680b895..15ca8afdd973 100644
--- a/drivers/platform/x86/intel/pmc/pltdrv.c
+++ b/drivers/platform/x86/intel/pmc/pltdrv.c
@@ -65,7 +65,7 @@ static int __init pmc_core_platform_init(void)
retval = platform_device_register(pmc_core_device);
if (retval)
- kfree(pmc_core_device);
+ platform_device_put(pmc_core_device);
return retval;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-25 10:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-22 10:50 [PATCH] platform/x86: intel_pmc_core: fix memleak on registration failure Johan Hovold
2021-12-22 11:05 ` Greg Kroah-Hartman
2021-12-23 18:47 ` Hans de Goede
2021-12-25 10:28 Simon Bursten
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).