diff mbox series

platform/x86: thinkpad_acpi: Fix a memory leak of EFCH MMIO resource

Message ID 20220621155511.5b266395@endymion.delvare (mailing list archive)
State Accepted, archived
Headers show
Series platform/x86: thinkpad_acpi: Fix a memory leak of EFCH MMIO resource | expand

Commit Message

Jean Delvare June 21, 2022, 1:55 p.m. UTC
Unlike release_mem_region(), a call to release_resource() does not
free the resource, so it has to be freed explicitly to avoid a memory
leak.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Fixes: 455cd867b85b ("platform/x86: thinkpad_acpi: Add a s2idle resume quirk for a number of laptops")
Cc: Mario Limonciello <mario.limonciello@amd.com>
Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Mark Gross <markgross@kernel.org>
---
 drivers/platform/x86/thinkpad_acpi.c |    1 +
 1 file changed, 1 insertion(+)

Comments

Mario Limonciello June 21, 2022, 5:54 p.m. UTC | #1
[Public]



> -----Original Message-----
> From: Jean Delvare <jdelvare@suse.de>
> Sent: Tuesday, June 21, 2022 08:55
> To: ibm-acpi-devel@lists.sourceforge.net; platform-driver-
> x86@vger.kernel.org
> Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>; Hans de Goede
> <hdegoede@redhat.com>; Mark Gross <markgross@kernel.org>;
> Limonciello, Mario <Mario.Limonciello@amd.com>
> Subject: [PATCH] platform/x86: thinkpad_acpi: Fix a memory leak of EFCH
> MMIO resource
> 
> Unlike release_mem_region(), a call to release_resource() does not
> free the resource, so it has to be freed explicitly to avoid a memory
> leak.
> 

Thanks for finding and fixing this.

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

> Signed-off-by: Jean Delvare <jdelvare@suse.de>
> Fixes: 455cd867b85b ("platform/x86: thinkpad_acpi: Add a s2idle resume
> quirk for a number of laptops")
> Cc: Mario Limonciello <mario.limonciello@amd.com>
> Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@kernel.org>
> ---
>  drivers/platform/x86/thinkpad_acpi.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> --- linux-5.18.orig/drivers/platform/x86/thinkpad_acpi.c	2022-05-22
> 21:52:31.000000000 +0200
> +++ linux-5.18/drivers/platform/x86/thinkpad_acpi.c	2022-06-21
> 15:49:31.705166709 +0200
> @@ -4529,6 +4529,7 @@ static void thinkpad_acpi_amd_s2idle_res
>  	iounmap(addr);
>  cleanup_resource:
>  	release_resource(res);
> +	kfree(res);
>  }
> 
>  static struct acpi_s2idle_dev_ops thinkpad_acpi_s2idle_dev_ops = {
> 
> 
> --
> Jean Delvare
> SUSE L3 Support
Jean Delvare June 21, 2022, 8:28 p.m. UTC | #2
On Tue, 21 Jun 2022 17:54:59 +0000, Limonciello, Mario wrote:
> > Unlike release_mem_region(), a call to release_resource() does not
> > free the resource, so it has to be freed explicitly to avoid a memory
> > leak.
> 
> Thanks for finding and fixing this.

To be honest, credits should go to Yi Zhang at Red Hat. He reported the
bug in another driver, all I did was checking if other drivers might
suffer from the same issue.

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

Thanks!
Hans de Goede June 22, 2022, 10:54 a.m. UTC | #3
Hi,

On 6/21/22 15:55, Jean Delvare wrote:
> Unlike release_mem_region(), a call to release_resource() does not
> free the resource, so it has to be freed explicitly to avoid a memory
> leak.
> 
> Signed-off-by: Jean Delvare <jdelvare@suse.de>
> Fixes: 455cd867b85b ("platform/x86: thinkpad_acpi: Add a s2idle resume quirk for a number of laptops")
> Cc: Mario Limonciello <mario.limonciello@amd.com>
> Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Cc: Mark Gross <markgross@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/thinkpad_acpi.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> --- linux-5.18.orig/drivers/platform/x86/thinkpad_acpi.c	2022-05-22 21:52:31.000000000 +0200
> +++ linux-5.18/drivers/platform/x86/thinkpad_acpi.c	2022-06-21 15:49:31.705166709 +0200
> @@ -4529,6 +4529,7 @@ static void thinkpad_acpi_amd_s2idle_res
>  	iounmap(addr);
>  cleanup_resource:
>  	release_resource(res);
> +	kfree(res);
>  }
>  
>  static struct acpi_s2idle_dev_ops thinkpad_acpi_s2idle_dev_ops = {
> 
>
diff mbox series

Patch

--- linux-5.18.orig/drivers/platform/x86/thinkpad_acpi.c	2022-05-22 21:52:31.000000000 +0200
+++ linux-5.18/drivers/platform/x86/thinkpad_acpi.c	2022-06-21 15:49:31.705166709 +0200
@@ -4529,6 +4529,7 @@  static void thinkpad_acpi_amd_s2idle_res
 	iounmap(addr);
 cleanup_resource:
 	release_resource(res);
+	kfree(res);
 }
 
 static struct acpi_s2idle_dev_ops thinkpad_acpi_s2idle_dev_ops = {