public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [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
* [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

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-25 10:28 [PATCH] platform/x86: intel_pmc_core: fix memleak on registration failure Simon Bursten
  -- strict thread matches above, loose matches on Subject: below --
2021-12-22 10:50 Johan Hovold
2021-12-22 11:05 ` Greg Kroah-Hartman
2021-12-23 18:47 ` 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