[PATCH v2] ACPI/resource.c: Fix memory leak reg
From: Maninder Singh
Date: Mon Jun 29 2015 - 04:11:51 EST
static analysis gives memory leak error for reg:-
[drivers/acpi/resource.c:663]: (error) Memory leak: reg
free allocated memory for reg in case of error from request_range
Signed-off-by: Maninder Singh <maninder1.s@xxxxxxxxxxx>
Reviewed-by: Akhilesh Kumar <akhilesh.k@xxxxxxxxxxx>
---
v1: allocate memory after request_range error checking
v2: free allocated memory in case of error as Suggested by
Jiang Liu <jiang.liu@xxxxxxxxxxxxxxx>
drivers/acpi/resource.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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;
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/