public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] asus-laptop: fix a memory leak in asus_laptop_get_info error path
@ 2010-06-29  3:09 Axel Lin
  2010-06-29  5:30 ` Corentin Chary
  2010-07-01 13:53 ` Matthew Garrett
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2010-06-29  3:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: Corentin Chary, Matthew Garrett, Len Brown, Alan Jenkins,
	acpi4asus-user, platform-driver-x86

The callers of write_acpi_int_ret() pass ACPI_ALLOCATE_BUFFER,
the caller must kfree the returned buffer if AE_OK is returned.

This patch adds a missing kfree(buffer.pointer) before return -ENOMEM
if kstrdup fail.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/platform/x86/asus-laptop.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
index 71db2ef..3d76c6a 100644
--- a/drivers/platform/x86/asus-laptop.c
+++ b/drivers/platform/x86/asus-laptop.c
@@ -1397,8 +1397,10 @@ static int asus_laptop_get_info(struct asus_laptop *asus)
 		}
 	}
 	asus->name = kstrdup(string, GFP_KERNEL);
-	if (!asus->name)
+	if (!asus->name) {
+		kfree(buffer.pointer);
 		return -ENOMEM;
+	}
 
 	if (*string)
 		pr_notice("  %s model detected\n", string);
-- 
1.5.4.3




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

* Re: [PATCH] asus-laptop: fix a memory leak in asus_laptop_get_info  error path
  2010-06-29  3:09 [PATCH] asus-laptop: fix a memory leak in asus_laptop_get_info error path Axel Lin
@ 2010-06-29  5:30 ` Corentin Chary
  2010-07-01 13:53 ` Matthew Garrett
  1 sibling, 0 replies; 3+ messages in thread
From: Corentin Chary @ 2010-06-29  5:30 UTC (permalink / raw)
  To: Axel Lin
  Cc: linux-kernel, Matthew Garrett, Len Brown, Alan Jenkins,
	acpi4asus-user, platform-driver-x86

On Tue, Jun 29, 2010 at 5:09 AM, Axel Lin <axel.lin@gmail.com> wrote:
> The callers of write_acpi_int_ret() pass ACPI_ALLOCATE_BUFFER,
> the caller must kfree the returned buffer if AE_OK is returned.
>
> This patch adds a missing kfree(buffer.pointer) before return -ENOMEM
> if kstrdup fail.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>  drivers/platform/x86/asus-laptop.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-laptop.c b/drivers/platform/x86/asus-laptop.c
> index 71db2ef..3d76c6a 100644
> --- a/drivers/platform/x86/asus-laptop.c
> +++ b/drivers/platform/x86/asus-laptop.c
> @@ -1397,8 +1397,10 @@ static int asus_laptop_get_info(struct asus_laptop *asus)
>                }
>        }
>        asus->name = kstrdup(string, GFP_KERNEL);
> -       if (!asus->name)
> +       if (!asus->name) {
> +               kfree(buffer.pointer);
>                return -ENOMEM;
> +       }
>
>        if (*string)
>                pr_notice("  %s model detected\n", string);
> --
> 1.5.4.3
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

Acked-by: Corentin Chary <corentincj@iksaif.net>

-- 
Corentin Chary
http://xf.iksaif.net

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

* Re: [PATCH] asus-laptop: fix a memory leak in asus_laptop_get_info error path
  2010-06-29  3:09 [PATCH] asus-laptop: fix a memory leak in asus_laptop_get_info error path Axel Lin
  2010-06-29  5:30 ` Corentin Chary
@ 2010-07-01 13:53 ` Matthew Garrett
  1 sibling, 0 replies; 3+ messages in thread
From: Matthew Garrett @ 2010-07-01 13:53 UTC (permalink / raw)
  To: Axel Lin
  Cc: linux-kernel, Corentin Chary, Len Brown, Alan Jenkins,
	acpi4asus-user, platform-driver-x86

On Tue, Jun 29, 2010 at 11:09:47AM +0800, Axel Lin wrote:
> The callers of write_acpi_int_ret() pass ACPI_ALLOCATE_BUFFER,
> the caller must kfree the returned buffer if AE_OK is returned.
> 
> This patch adds a missing kfree(buffer.pointer) before return -ENOMEM
> if kstrdup fail.

Applied, thanks.

-- 
Matthew Garrett | mjg59@srcf.ucam.org

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

end of thread, other threads:[~2010-07-01 13:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-29  3:09 [PATCH] asus-laptop: fix a memory leak in asus_laptop_get_info error path Axel Lin
2010-06-29  5:30 ` Corentin Chary
2010-07-01 13:53 ` Matthew Garrett

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