From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_DBL_ABUSE_MALW,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A94DC33CB3 for ; Thu, 30 Jan 2020 11:02:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 33FBA206F0 for ; Thu, 30 Jan 2020 11:02:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZVPGGFvE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33FBA206F0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KRc35OvaZ3j5JJevFINCFvZxq6KltmC/gGhn0YhD8zo=; b=ZVPGGFvExI+kD+ 58D/FCT7a0IKZBAKupoJ7ZVSPX8T0wqDY47/OnmF5HHPtdNHmgAgXDG1gJDahlSSlXeYtPRYBH8C8 d++q97t9KM/wxN9QDU+/Nq1RYuj3Sxwu2TWDG2i+Xe5uicHOfWK1gKVxVSyQuT1+OD4ghw0aN/ICS zpx5ZdvXAeYSHVOTXbquBzJNcrxv0dKNi2WeDMEYcjjJNY8lamYj8947gerIonf6zHKBkPqatc/Gz TbKjzYGNYPv/yZqjM4Q7J2e4Vygn/A8H6T0ozyB4qnzGpZi+vg5IcuKBWjKDgT70mvZ8VGdlpNhzf fUISCRNZQQ1AFKEqen/g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ix7ay-0004em-W9; Thu, 30 Jan 2020 11:02:49 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ix7av-0004eI-Da for linux-arm-kernel@lists.infradead.org; Thu, 30 Jan 2020 11:02:46 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4EEC6328; Thu, 30 Jan 2020 03:02:42 -0800 (PST) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 845C23F67D; Thu, 30 Jan 2020 03:02:41 -0800 (PST) Date: Thu, 30 Jan 2020 11:02:39 +0000 From: Sudeep Holla To: Gavin Shan Subject: Re: [PATCH] drivers/firmware/psci: Fix memory leak in alloc_init_cpu_groups() Message-ID: <20200130110239.GC48466@bogus> References: <20200130034938.158504-1-gshan@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200130034938.158504-1-gshan@redhat.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200130_030245_503048_DFC0A011 X-CRM114-Status: GOOD ( 15.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, lorenzo.pieralisi@arm.com, linux-arm-kernel@lists.infradead.org, Sudeep Holla Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jan 30, 2020 at 02:49:38PM +1100, Gavin Shan wrote: > The CPU mask (@tmp) should be free'd on failing to allocating the element > of @cpu_groups[]. Otherwise, it leads to memory leakage because the CPU > mask variable is allocated with CONFIG_CPUMASK_OFFSTACK. > > Signed-off-by: Gavin Shan > --- > drivers/firmware/psci/psci_checker.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/firmware/psci/psci_checker.c b/drivers/firmware/psci/psci_checker.c > index 6a445397771c..d1d6d1135fed 100644 > --- a/drivers/firmware/psci/psci_checker.c > +++ b/drivers/firmware/psci/psci_checker.c > @@ -167,6 +167,7 @@ static int alloc_init_cpu_groups(cpumask_var_t **pcpu_groups) > topology_core_cpumask(cpumask_any(tmp)); > > if (!alloc_cpumask_var(&cpu_groups[num_groups], GFP_KERNEL)) { > + free_cpumask_var(tmp); You may need also below diff, right ? -->8 diff --git i/drivers/firmware/psci/psci_checker.c w/drivers/firmware/psci/psci_checker.c index 6a445397771c..c5a5c76a9fda 100644 --- i/drivers/firmware/psci/psci_checker.c +++ w/drivers/firmware/psci/psci_checker.c @@ -157,8 +157,10 @@ static int alloc_init_cpu_groups(cpumask_var_t **pcpu_groups) cpu_groups = kcalloc(nb_available_cpus, sizeof(cpu_groups), GFP_KERNEL); - if (!cpu_groups) + if (!cpu_groups) { + free_cpumask_var(tmp); return -ENOMEM; + } cpumask_copy(tmp, cpu_online_mask); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel