Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752209AbbF2Gel (ORCPT ); Mon, 29 Jun 2015 02:34:41 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:50871 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750718AbbF2Gec (ORCPT ); Mon, 29 Jun 2015 02:34:32 -0400 X-AuditID: cbfee68e-f79c56d000006efb-2d-5590e6f5c2d3 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, Maninder Singh Subject: [PATCH 1/1] ACPI/resource.c: Fixing memory leak for reg Date: Mon, 29 Jun 2015 12:04:00 +0530 Message-id: <1435559640-18059-1-git-send-email-maninder1.s@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOLMWRmVeSWpSXmKPExsWyRsSkWvfbswmhBst/MVnsfPiWzWL5vn5G i8u75rBZHJ7fxmJx781WJoszpy+xOrB5bFrVyeax5Wo7i0ffllWMHp83yQWwRHHZpKTmZJal FunbJXBltPXvZyuYxlGxd98V1gbGm2xdjJwcEgImEmfPrISyxSQu3FsPZgsJLGWUOHjPDKam YUYrUxcjF1B8EaPE7U8gDSDOT0aJD1PesoNUsQnoSazatYcFxBYRSJLYfvcyaxcjBwezgJPE 9K96IGFhAQeJrll3mUFsFgFVideP9zCC2LwC7hJnf/xjAimXEFCQmDPJBmS8hMBnNomLu5sZ IeoFJL5NPsQCUSMrsekAM8RtkhIHV9xgmcAouICRYRWjaGpBckFxUnqRkV5xYm5xaV66XnJ+ 7iZGYHie/vesbwfjzQPWhxgFOBiVeHgtHk4IFWJNLCuuzD3EaAq0YSKzlGhyPjAK8kriDY3N jCxMTUyNjcwtzZTEeROkfgYLCaQnlqRmp6YWpBbFF5XmpBYfYmTi4JRqYGz+GZSl2nGmKuHD Vi/fOUE5DB0PLdUXvs41Mnh/j+sCRwc7r6j1hdXPlZf7TGvq0urbejhY8N3lnkPLdSZx7Ljg 9yrjtKX0t+Tv2UkfFNVtbdQ2BmrcOjHz1cllQVPr128TffH/6ZJbkx9nRCafvSZ280lIyy6J DW9F+ve9qKk9XZi736+zWkeJpTgj0VCLuag4EQD3sl8ASgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpikeLIzCtJLcpLzFFi42I5/e+xgO7XZxNCDWb9tbDY+fAtm8Xyff2M Fpd3zWGzODy/jcXi3putTBZnTl9idWDz2LSqk81jy9V2Fo++LasYPT5vkgtgiWpgtMlITUxJ LVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wB2q6kUJaYUwoUCkgs LlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzGjr389WMI2jYu++K6wNjDfZuhg5OSQETCQa ZrQyQdhiEhfurQeKc3EICSxilLj9aSWU85NR4sOUt+wgVWwCehKrdu1hAbFFBJIktt+9zNrF yMHBLOAkMf2rHkhYWMBBomvWXWYQm0VAVeL14z2MIDavgLvE2R//mEDKJQQUJOZMspnAyL2A kWEVo2hqQXJBcVJ6rpFecWJucWleul5yfu4mRnD4P5PewbiqweIQowAHoxIP74unE0KFWBPL iitzDzFKcDArifBe3gwU4k1JrKxKLcqPLyrNSS0+xGgKtHwis5Rocj4wNvNK4g2NTcxNjU0t TSxMzCyVxHlP5vuECgmkJ5akZqemFqQWwfQxcXBKNTByCMYYJQa8+jLTLu3f4ViDw/6CobOE v08x3uxeu+LSp2Qzy4UV7hOPKDLsmjDBU7ek0e7AmYNvSr80ab1NNv2z7Xx2yfOHvZ3iCew2 ur0isQpfZ20ryZvi1nbbZ6nI/luulW5nJ2QWmpTO38p53M/wZV/tCe7wWwtnvWRVfrP54JqL kwT1dPqUWIozEg21mIuKEwEDCTnXlQIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1253 Lines: 43 static analysis gives memory leak error for reg:- [drivers/acpi/resource.c:663]: (error) Memory leak: reg Thus to prevent this allocate memory for reg after request_range error checking. Signed-off-by: Maninder Singh Reviewed-by: Akhilesh Kumar --- drivers/acpi/resource.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c index fcb7807..f942b70 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c @@ -655,14 +655,14 @@ static int add_region_before(u64 start, u64 end, u8 space_id, struct reserved_region *reg; int error; - reg = kmalloc(sizeof(*reg), GFP_KERNEL); - if (!reg) - return -ENOMEM; - error = request_range(start, end, space_id, flags, desc); if (error) return error; + reg = kmalloc(sizeof(*reg), GFP_KERNEL); + if (!reg) + return -ENOMEM; + reg->start = start; reg->end = end; list_add_tail(®->node, head); -- 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/