diff mbox

ACPI / resources: free memory on error in add_region_before()

Message ID 20150624143015.GD1702@mwanda (mailing list archive)
State Accepted, archived
Delegated to: Rafael Wysocki
Headers show

Commit Message

Dan Carpenter June 24, 2015, 2:30 p.m. UTC
There is a small memory leak on error.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Rafael J. Wysocki June 24, 2015, 9:57 p.m. UTC | #1
On Wednesday, June 24, 2015 05:30:15 PM Dan Carpenter wrote:
> There is a small memory leak on error.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks!

> diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
> index fcb7807..10561ce 100644
> --- a/drivers/acpi/resource.c
> +++ b/drivers/acpi/resource.c
> @@ -660,8 +660,10 @@ static int add_region_before(u64 start, u64 end, u8 space_id,
>  		return -ENOMEM;
>  
>  	error = request_range(start, end, space_id, flags, desc);
> -	if (error)
> +	if (error) {
> +		kfree(reg);
>  		return error;
> +	}
>  
>  	reg->start = start;
>  	reg->end = end;
diff mbox

Patch

diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c
index fcb7807..10561ce 100644
--- a/drivers/acpi/resource.c
+++ b/drivers/acpi/resource.c
@@ -660,8 +660,10 @@  static int add_region_before(u64 start, u64 end, u8 space_id,
 		return -ENOMEM;
 
 	error = request_range(start, end, space_id, flags, desc);
-	if (error)
+	if (error) {
+		kfree(reg);
 		return error;
+	}
 
 	reg->start = start;
 	reg->end = end;