Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752886AbbF2ILp (ORCPT ); Mon, 29 Jun 2015 04:11:45 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:54348 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752119AbbF2ILf (ORCPT ); Mon, 29 Jun 2015 04:11:35 -0400 X-AuditID: cbfee690-f796f6d000005054-96-5590fdb58175 From: Maninder Singh To: rjw@rjwysocki.net, lenb@kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: pankaj.m@samsung.com, jiang.liu@linux.intel.com, Maninder Singh Subject: [PATCH v2] ACPI/resource.c: Fix memory leak reg Date: Mon, 29 Jun 2015 13:40:26 +0530 Message-id: <1435565426-42571-1-git-send-email-maninder1.s@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrILMWRmVeSWpSXmKPExsWyRsSkTnfr3wmhBk8buS1mbd/PYrHz4Vs2 i+X7+hktLu+aw2ZxeH4bi8W9N1uZLM6cvsTqwO6xaVUnm8e8k4EeW662s3j0bVnF6PF5k1wA axSXTUpqTmZZapG+XQJXxos7P9kLnrJXtHW/Z29g3MDWxcjJISFgIrFqXzsjhC0mceHeeqA4 F4eQwFJGib3rj7PCFLVtbmQBsYUEFjFKvGnygyj6ySix/NcJdpAEm4CexKpde8CKRASSJLbf vQzWzCwQL/Hr2wkmEFtYwEJi1exFYJtZBFQlFj35DtbLK+AuMWl3J1A9B9AyBYk5k2xA5ksI /GaTODqjjRmiXkDi2+RDLBA1shKbDjBD3CYpcXDFDZYJjIILGBlWMYqmFiQXFCelF5noFSfm Fpfmpesl5+duYgSG7Ol/zybsYLx3wPoQowAHoxIPr+OLCaFCrIllxZW5hxhNgTZMZJYSTc4H RkZeSbyhsZmRhamJqbGRuaWZkjjva6mfwUIC6YklqdmpqQWpRfFFpTmpxYcYmTg4pRoYl0+O TFnk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S X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1208 Lines: 39 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 Reviewed-by: Akhilesh Kumar --- v1: allocate memory after request_range error checking v2: free allocated memory in case of error as Suggested by Jiang Liu 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/