Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp204332imw; Fri, 15 Jul 2022 01:10:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vYTSwkv8nnQaehu8omAuUtuz2raZiEwAW0c8934A05StoSWLIreB8IAz3eIRprFuwKlG98 X-Received: by 2002:a63:ea55:0:b0:412:290c:9694 with SMTP id l21-20020a63ea55000000b00412290c9694mr11317344pgk.39.1657872624750; Fri, 15 Jul 2022 01:10:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657872624; cv=none; d=google.com; s=arc-20160816; b=ire1lye1SB/hso1tACYO+y4lGboW/5gHrfcsb2M1vVq+7k0mffDFfIN/Jr6CyTX/IG VHSThiCh1ipQuL+It2HrQNXvtBg2Xc/DF+pkoO2BbRQIcQ7km3Hk/pBcanYYA8iDAXft dsbd+sTzh7P89qlHiW5Gq0xR3jKAgsxzRUTmaOmnOEUXDGKTp2FFYPiDcdZvfzOf42lj gQIs/sB86OczP6nfbDj4qEJQ8ivfmOPSwdlNsXuKUCEjlNH5/KFhcypcpGrmbuEHg+p3 QNMqg6g9FaImqdmyZAbwstWbIuRse3YXXtpYMgo2myGRlGLh38oodRoOZAyV5TsAZxqm xc8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=hWZIAURheiUwOzMoQ+x4bybNAkJFDtLhvv33FlPT33U=; b=eiXfEAF2IlqssXXKsMONJNFfk5UwZAr3PARYw5yrWQ61b4ox5PHjU8KhPmowj7bhsZ mx67TSdoOqoQc2BRCV8R+0owuHYH0Kxj8tB4XmmXjDF1XWtTkKqTSl0oBytL54ePjCXA kTmy0tiwBHCg3+4MTiwN2aFYmsYxNB9W4cnN2Url6yOyQqPYVb5NREOwkW7dCmumI2I7 +THJJlNz8p+uUJuKzMGxEXBHhuzJq+TJMHd2kw9/l5CTPGHbR+jbhMCfyp8RLB+NBmV8 4SUQ7k0jX9HZbD5xQgktEHgvczaeEEJHrvqTLh1KtmIGWTTWjr32NX/O29lfqpETxoDp 35mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e18-20020a63e012000000b00419ae71dafesi5082927pgh.450.2022.07.15.01.09.50; Fri, 15 Jul 2022 01:10:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232371AbiGOHti (ORCPT + 99 others); Fri, 15 Jul 2022 03:49:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232365AbiGOHtf (ORCPT ); Fri, 15 Jul 2022 03:49:35 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00C5D78DC4 for ; Fri, 15 Jul 2022 00:49:30 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id 21A4B3D9; Fri, 15 Jul 2022 09:49:29 +0200 (CEST) Date: Fri, 15 Jul 2022 09:49:27 +0200 From: Joerg Roedel To: Yang Yingliang Cc: linux-kernel@vger.kernel.org, iommu@lists.linux.dev, iommu@lists.linux-foundation.org, will@kernel.org, yf.wang@mediatek.com, Robin Murphy Subject: Re: [PATCH -next] iommu/dma: Fix missing mutex_init() in iommu_get_msi_cookie() Message-ID: References: <20220627085533.1469141-1-yangyingliang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220627085533.1469141-1-yangyingliang@huawei.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding Robin. On Mon, Jun 27, 2022 at 04:55:33PM +0800, Yang Yingliang wrote: > cookie_alloc() is called by iommu_get_dma_cookie() and iommu_get_msi_cookie(), > but the mutex is only initialized in iommu_get_dma_cookie(), move mutex_init() > into cookie_alloc() to make sure the mutex will be initialized. > > Fixes: ac9a5d522bb8 ("iommu/dma: Fix race condition during iova_domain initialization") > Reported-by: Hulk Robot > Signed-off-by: Yang Yingliang > --- > drivers/iommu/dma-iommu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c > index 1910f4f1612b..e29157380c48 100644 > --- a/drivers/iommu/dma-iommu.c > +++ b/drivers/iommu/dma-iommu.c > @@ -294,6 +294,7 @@ static struct iommu_dma_cookie *cookie_alloc(enum iommu_dma_cookie_type type) > if (cookie) { > INIT_LIST_HEAD(&cookie->msi_page_list); > cookie->type = type; > + mutex_init(&cookie->mutex); > } > return cookie; > } > @@ -311,7 +312,6 @@ int iommu_get_dma_cookie(struct iommu_domain *domain) > if (!domain->iova_cookie) > return -ENOMEM; > > - mutex_init(&domain->iova_cookie->mutex); > return 0; > } > > -- > 2.25.1