From patchwork Tue Jun 22 15:53:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boqun Feng X-Patchwork-Id: 12337917 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 17567C2B9F4 for ; Tue, 22 Jun 2021 15:55:54 +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 DC8EE61040 for ; Tue, 22 Jun 2021 15:55:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC8EE61040 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=K4odUA0etF/ZaacBrq8+9H6A73NI90l8CowMZAueeaY=; b=0nOMJ/Xzc/4jJq 6stulg0VIgPCYhWIbAg1LBP4HJmS0VgR/gv8VYE7ozJYyoG+Z//U5c1D1Bs+hLHQgHemQMTYQNDGd Kz123BAjxc5fZiqgEB4SK2pIVj3mbFYPFGEyQRNZO1iwyYgnonmjiRqXSdc8qNikbJrI899s+y3hW tzWAGWhhlwGEVcWLOL7owX7J4k+sGLXpmlljlgTdwxN638soCqz37k7Y35OREBB3yjlsGrmsGK6fb Z+BZRwXxfHzyW6DnrqSxkZH1yqYhjdkb17WNJ2xpeKM7ajCotxkSL6QcrHtXFPSxLTP/fQzVZKYQC Clq+opOLIVyAzFryvzgQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lvij8-007nsK-1Z; Tue, 22 Jun 2021 15:54:14 +0000 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lviit-007noq-9K for linux-arm-kernel@lists.infradead.org; Tue, 22 Jun 2021 15:54:00 +0000 Received: by mail-io1-xd30.google.com with SMTP id f10so14962334iok.6 for ; Tue, 22 Jun 2021 08:53:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uDOOz7CrZ9gkU8joR8mG9wvpIFsLuCmb5gkXvkTbNx4=; b=larp1gH6LLvQuhDjorYmFdNvfyPgcQIE25q0djLLAo5HQsbYLADB67Zyautet9o0Es L80lI8COTBYV/F3o05vyePkIqMcbGdz5mGK0bhhYkxIt4Igk3x+d2IB91OdZK//H3wHG 2Bna/Pa/buAvxoSh0sGG0JjJ3Ny7HZvEpq7119IYxqcdz2pDfWIVdh6SZd/mI4GCeEGf mhssPhJ69pGcdfEKhCG6IVRmwRsYx9ByO7dbt8ByUvC+00albk9IUYMPwXntbQaPusIs yldFP2oZQL2+VZibRZ+Na7fhtSJU68gBfEdpyDI0hq0Xpvz7SnM5TyFLlELkd1pMZ2hB jxcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uDOOz7CrZ9gkU8joR8mG9wvpIFsLuCmb5gkXvkTbNx4=; b=do/MIjKJplBZbXY/T8tfJlYXaeWvyCbWn/s5334MO2pi6Rh05Zme4x+DS1C3f60ll3 kB2vWTEXMNBfGbaG9F7HsVnDr6j7KZyZwM4U2wEcnEe0AW2wFbNEv3YOkRf5uOOLs/yD J0WptfeYvurWZhyOvyRHC0h/yUfKJ6B9m3YR4Xg0Jtop7iVKhk2IQRn12omvq/CZbP++ FJjGXm7Bb+KdIUhL/PaOPh50Hl6qeOGzA9N6mpHkGHjZIZKPg4xCsn0vOUyrwD1kFyIl amB5EenCLJG4sTO4hEZidFNsNju71lD16RFj3Ie4+5fGNixF67sFCf89gLIShOtJ3g8A emoQ== X-Gm-Message-State: AOAM5331+1RN0hXsGzBotE4hhxtjmIdOqe33ALwg0DUpYxMGc3uigg7S Ht+7m0rI0GbhMo/yMmba+Y0= X-Google-Smtp-Source: ABdhPJxf/6sMUiu2f9sZO3YdItnt3YwbpJrw0apYAO2E3TKoEaeSayspearG7gaJ/19Q9n0ZUBXsyg== X-Received: by 2002:a02:5d0a:: with SMTP id w10mr4576618jaa.82.1624377237762; Tue, 22 Jun 2021 08:53:57 -0700 (PDT) Received: from auth2-smtp.messagingengine.com (auth2-smtp.messagingengine.com. [66.111.4.228]) by smtp.gmail.com with ESMTPSA id m13sm7965687iob.35.2021.06.22.08.53.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Jun 2021 08:53:57 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailauth.nyi.internal (Postfix) with ESMTP id BC31227C005A; Tue, 22 Jun 2021 11:53:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Tue, 22 Jun 2021 11:53:56 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeeguddgleegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpeeuohhquhhn ucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrfgrth htvghrnhephedvveetfefgiedutedtfeevvddvleekjeeuffffleeguefhhfejteekieeu ueelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepsg hoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedtieeg qddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfhhigi hmvgdrnhgrmhgv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 22 Jun 2021 11:53:56 -0400 (EDT) From: Boqun Feng To: Marc Zyngier Cc: Thomas Gleixner , linux-kernel@vger.kernel.org, Arnd Bergmann , Bjorn Helgaas , Linux ARM , Catalin Marinas , Will Deacon , Boqun Feng Subject: [RFC 1/2] irqchip/gic-v3-its: Free collections if its domain initialization fails Date: Tue, 22 Jun 2021 23:53:12 +0800 Message-Id: <20210622155313.3819952-2-boqun.feng@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210622155313.3819952-1-boqun.feng@gmail.com> References: <20210622155313.3819952-1-boqun.feng@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210622_085359_367249_F9982612 X-CRM114-Status: GOOD ( 13.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org ITS collections are allocated before its_init_domain() called in its_init(), therefore if its_init_domain() fails, the collections need to be freed. This fixes a potential memory leak. Signed-off-by: Boqun Feng --- drivers/irqchip/irq-gic-v3-its.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 2e6923c2c8a8..1916ac5d6371 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -2931,6 +2931,12 @@ static int its_alloc_collections(struct its_node *its) return 0; } +static void its_free_collections(struct its_node *its) +{ + if (its) + kfree(its->collections); +} + static struct page *its_allocate_pending_table(gfp_t gfp_flags) { struct page *pend_page; @@ -5090,7 +5096,7 @@ static int __init its_probe_one(struct resource *res, err = its_init_domain(handle, its); if (err) - goto out_free_tables; + goto out_free_collections; raw_spin_lock(&its_lock); list_add(&its->entry, &its_nodes); @@ -5098,6 +5104,8 @@ static int __init its_probe_one(struct resource *res, return 0; +out_free_collections: + its_free_collections(its); out_free_tables: its_free_tables(its); out_free_cmd: