public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [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; 3+ 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] 3+ messages in thread

end of thread, other threads:[~2021-12-23 18:48 UTC | newest]

Thread overview: 3+ 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox