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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 0AE66CD128A for ; Mon, 1 Apr 2024 16:40:56 +0000 (UTC) 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:Subject:CC: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=vQ/7ivMG5Hj/SQxVmGj5b44zJJonqsdAO6R9aYyRwjU=; b=n9DxyMAyCRk2vF RLfHbIlV0jsaL7WUxbIn+IQTminIYvq8m4/GvN8GzFwL39gyeWmDIaID0MG3bQzWlGyhpyp4JK1li j+anwUDmYZGiRsiztBWGaLQWkAn+hBirHdDlj4nIebtN5PeF/HQKXXAi9RSZyBMTNn8mHktJum8LQ xOnDtiqL3ZGgMiDdwnwcw786HdW9zb+YYd4B/nyhdYS3ghdk0h/aXDRaqIkGQzIGy70RqZ2FiUV0P jAEFd2s2GAlJLu/WsiXtRN4sv097a/7/tlXPLwOcUucCOSlVfTXCvncl1YKyjKbKogEMmOcDDKKz4 r43NElm45SqDJOlTStlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrKi9-00000008LlM-3bbg; Mon, 01 Apr 2024 16:40:41 +0000 Received: from frasgout.his.huawei.com ([185.176.79.56]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rrKi3-00000008Lib-1oVG for linux-arm-kernel@lists.infradead.org; Mon, 01 Apr 2024 16:40:39 +0000 Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4V7cCp0fbxz6K5t9; Tue, 2 Apr 2024 00:39:02 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 92DB71400D1; Tue, 2 Apr 2024 00:40:12 +0800 (CST) Received: from localhost (10.48.156.172) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 1 Apr 2024 17:40:11 +0100 Date: Mon, 1 Apr 2024 17:40:09 +0100 From: Jonathan Cameron To: Aleksandr Aprelkov CC: Will Deacon , Robin Murphy , Joerg Roedel , Jason Gunthorpe , "Nicolin Chen" , Michael Shavit , Lu Baolu , Marc Zyngier , , , Subject: Re: [PATCH] iommu/arm-smmu-v3: Free MSIs in case of ENOMEM Message-ID: <20240401174009.00003644@Huawei.com> In-Reply-To: <20240329095133.576605-1-aaprelkov@usergate.com> References: <20240329095133.576605-1-aaprelkov@usergate.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) MIME-Version: 1.0 X-Originating-IP: [10.48.156.172] X-ClientProxiedBy: lhrpeml500005.china.huawei.com (7.191.163.240) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240401_094037_790370_2785884D X-CRM114-Status: GOOD ( 18.96 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 29 Mar 2024 16:51:33 +0700 Aleksandr Aprelkov wrote: > If devm_add_action() returns ENOMEM, then MSIs allocated but > not freed on teardown. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: 166bdbd23161 ("iommu/arm-smmu: Add support for MSI on SMMUv3") > Signed-off-by: Aleksandr Aprelkov I've not checked this is an actual bug (though it looks like one from the context of the patch - the comment below is just about how you fix it. > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > index 41f93c3ab160..136d0cdce6a9 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -3402,7 +3402,12 @@ static void arm_smmu_setup_msis(struct arm_smmu_device *smmu) > smmu->priq.q.irq = msi_get_virq(dev, PRIQ_MSI_INDEX); > > /* Add callback to free MSIs on teardown */ > - devm_add_action(dev, arm_smmu_free_msis, dev); > + ret = devm_add_action(dev, arm_smmu_free_msis, dev); Use devm_add_action_or_reset() which exists to solve the case of devm registration failing. > + if (ret) { > + dev_warn(dev, "failed to add free MSIs callback - falling back to wired irqs\n"); > + arm_smmu_free_msis(dev); > + return; > + } > } > > static void arm_smmu_setup_unique_irqs(struct arm_smmu_device *smmu) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel