linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [resend] ACPI: Fix memory leak in acpi_bind_one() (fwd)
@ 2012-10-15 18:51 Jesper Juhl
  2012-10-15 20:01 ` Toshi Kani
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Jesper Juhl @ 2012-10-15 18:51 UTC (permalink / raw)
  To: linux-acpi; +Cc: linux-kernel, Len Brown

Ok, so I had a little problem with my mail servers clock that caused the 
mail below to be timestamped a few years in the past, so I assume noone 
saw it - thus, resending.

-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


---------- Forwarded message ----------
Date: Sun, 9 Nov 2008 14:38:30 +0100 (CET)
From: Jesper Juhl <jj@chaosbits.net>
To: linux-acpi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Len Brown <lenb@kernel.org>
Subject: [PATCH] ACPI: Fix memory leak in acpi_bind_one()

Memory is allocated with kzalloc() and assigned to
'physical_node'. Then 'physical_node->node_id' is initialized with a
call to 'find_first_zero_bit()', if that results in a value greater
than ACPI_MAX_PHYSICAL_NODE we'll end up jumping to the 'err:' label
and there leave the function and let 'physical_node' go out of scope
and leak the memory we allocated.
This patch fixes the leak by simply freeing the unused/unneeded memory
pointed to by 'physical_node' just before we jump to 'err:'.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 drivers/acpi/glue.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index d1a2d74..0837308 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -159,6 +159,7 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
 	if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) {
 		retval = -ENOSPC;
 		mutex_unlock(&acpi_dev->physical_node_lock);
+		kfree(physical_node);
 		goto err;
 	}
 
-- 
1.7.1


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


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

* Re: [PATCH] [resend] ACPI: Fix memory leak in acpi_bind_one() (fwd)
  2012-10-15 18:51 [PATCH] [resend] ACPI: Fix memory leak in acpi_bind_one() (fwd) Jesper Juhl
@ 2012-10-15 20:01 ` Toshi Kani
  2012-10-16  0:17 ` Yasuaki Ishimatsu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Toshi Kani @ 2012-10-15 20:01 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-acpi, linux-kernel, Len Brown

On Mon, 2012-10-15 at 20:51 +0200, Jesper Juhl wrote:
> Ok, so I had a little problem with my mail servers clock that caused the 
> mail below to be timestamped a few years in the past, so I assume noone 
> saw it - thus, resending.
> 
> -- 
> Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
> Don't top-post http://www.catb.org/jargon/html/T/top-post.html
> Plain text mails only, please.
> 
> 
> ---------- Forwarded message ----------
> Date: Sun, 9 Nov 2008 14:38:30 +0100 (CET)
> From: Jesper Juhl <jj@chaosbits.net>
> To: linux-acpi@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org, Len Brown <lenb@kernel.org>
> Subject: [PATCH] ACPI: Fix memory leak in acpi_bind_one()
> 
> Memory is allocated with kzalloc() and assigned to
> 'physical_node'. Then 'physical_node->node_id' is initialized with a
> call to 'find_first_zero_bit()', if that results in a value greater
> than ACPI_MAX_PHYSICAL_NODE we'll end up jumping to the 'err:' label
> and there leave the function and let 'physical_node' go out of scope
> and leak the memory we allocated.
> This patch fixes the leak by simply freeing the unused/unneeded memory
> pointed to by 'physical_node' just before we jump to 'err:'.
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>

Looks good.

Reviewed-by: Toshi Kani <toshi.kani@hp.com>

-Toshi

> ---
>  drivers/acpi/glue.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
> index d1a2d74..0837308 100644
> --- a/drivers/acpi/glue.c
> +++ b/drivers/acpi/glue.c
> @@ -159,6 +159,7 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
>  	if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) {
>  		retval = -ENOSPC;
>  		mutex_unlock(&acpi_dev->physical_node_lock);
> +		kfree(physical_node);
>  		goto err;
>  	}
>  
> -- 
> 1.7.1
> 
> 



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

* Re: [PATCH] [resend] ACPI: Fix memory leak in acpi_bind_one() (fwd)
  2012-10-15 18:51 [PATCH] [resend] ACPI: Fix memory leak in acpi_bind_one() (fwd) Jesper Juhl
  2012-10-15 20:01 ` Toshi Kani
@ 2012-10-16  0:17 ` Yasuaki Ishimatsu
  2012-10-16 19:14 ` David Rientjes
  2012-10-24 22:10 ` Rafael J. Wysocki
  3 siblings, 0 replies; 5+ messages in thread
From: Yasuaki Ishimatsu @ 2012-10-16  0:17 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-acpi, linux-kernel, Len Brown

On Mon, 2012-10-15 at 20:51 +0200, Jesper Juhl wrote:
> Ok, so I had a little problem with my mail servers clock that caused the
> mail below to be timestamped a few years in the past, so I assume noone
> saw it - thus, resending.
>
> --
> Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
> Don't top-post http://www.catb.org/jargon/html/T/top-post.html
> Plain text mails only, please.
>
>
> ---------- Forwarded message ----------
> Date: Sun, 9 Nov 2008 14:38:30 +0100 (CET)
> From: Jesper Juhl <jj@chaosbits.net>
> To: linux-acpi@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org, Len Brown <lenb@kernel.org>
> Subject: [PATCH] ACPI: Fix memory leak in acpi_bind_one()
>
> Memory is allocated with kzalloc() and assigned to
> 'physical_node'. Then 'physical_node->node_id' is initialized with a
> call to 'find_first_zero_bit()', if that results in a value greater
> than ACPI_MAX_PHYSICAL_NODE we'll end up jumping to the 'err:' label
> and there leave the function and let 'physical_node' go out of scope
> and leak the memory we allocated.
> This patch fixes the leak by simply freeing the unused/unneeded memory
> pointed to by 'physical_node' just before we jump to 'err:'.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>

Looks good to me.

Reviewed-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>

Thanks,
Yasuaki Ishimatsu

> ---
>  drivers/acpi/glue.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
> index d1a2d74..0837308 100644
> --- a/drivers/acpi/glue.c
> +++ b/drivers/acpi/glue.c
> @@ -159,6 +159,7 @@ static int acpi_bind_one(struct device *dev, acpi_handle handle)
>  	if (physical_node->node_id >= ACPI_MAX_PHYSICAL_NODE) {
>  		retval = -ENOSPC;
>  		mutex_unlock(&acpi_dev->physical_node_lock);
> +		kfree(physical_node);
>  		goto err;
>  	}
>
> --
> 1.7.1
>
>



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

* Re: [PATCH] [resend] ACPI: Fix memory leak in acpi_bind_one() (fwd)
  2012-10-15 18:51 [PATCH] [resend] ACPI: Fix memory leak in acpi_bind_one() (fwd) Jesper Juhl
  2012-10-15 20:01 ` Toshi Kani
  2012-10-16  0:17 ` Yasuaki Ishimatsu
@ 2012-10-16 19:14 ` David Rientjes
  2012-10-24 22:10 ` Rafael J. Wysocki
  3 siblings, 0 replies; 5+ messages in thread
From: David Rientjes @ 2012-10-16 19:14 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-acpi, linux-kernel, Len Brown

On Mon, 15 Oct 2012, Jesper Juhl wrote:

> Memory is allocated with kzalloc() and assigned to
> 'physical_node'. Then 'physical_node->node_id' is initialized with a
> call to 'find_first_zero_bit()', if that results in a value greater
> than ACPI_MAX_PHYSICAL_NODE we'll end up jumping to the 'err:' label
> and there leave the function and let 'physical_node' go out of scope
> and leak the memory we allocated.
> This patch fixes the leak by simply freeing the unused/unneeded memory
> pointed to by 'physical_node' just before we jump to 'err:'.
> 
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>

Acked-by: David Rientjes <rientjes@google.com>

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

* Re: [PATCH] [resend] ACPI: Fix memory leak in acpi_bind_one() (fwd)
  2012-10-15 18:51 [PATCH] [resend] ACPI: Fix memory leak in acpi_bind_one() (fwd) Jesper Juhl
                   ` (2 preceding siblings ...)
  2012-10-16 19:14 ` David Rientjes
@ 2012-10-24 22:10 ` Rafael J. Wysocki
  3 siblings, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2012-10-24 22:10 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: linux-acpi, linux-kernel, Len Brown, Toshi Kani,
	Yasuaki Ishimatsu, David Rientjes

On Monday 15 of October 2012 20:51:11 Jesper Juhl wrote:
> Ok, so I had a little problem with my mail servers clock that caused the 
> mail below to be timestamped a few years in the past, so I assume noone 
> saw it - thus, resending.

Applied to linux-pm.git/linux-next as v3.7 material, will be included in the
next linux-pm push.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

end of thread, other threads:[~2012-10-24 22:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-15 18:51 [PATCH] [resend] ACPI: Fix memory leak in acpi_bind_one() (fwd) Jesper Juhl
2012-10-15 20:01 ` Toshi Kani
2012-10-16  0:17 ` Yasuaki Ishimatsu
2012-10-16 19:14 ` David Rientjes
2012-10-24 22:10 ` Rafael J. Wysocki

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).