From nobody Sun Apr 19 20:36:17 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF5D3C433EF for ; Mon, 27 Jun 2022 08:45:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233638AbiF0Ipo (ORCPT ); Mon, 27 Jun 2022 04:45:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233019AbiF0Ipj (ORCPT ); Mon, 27 Jun 2022 04:45:39 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 906B1631E for ; Mon, 27 Jun 2022 01:45:38 -0700 (PDT) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LWh9H1MqMzkWnN; Mon, 27 Jun 2022 16:44:19 +0800 (CST) Received: from dggpemm500007.china.huawei.com (7.185.36.183) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 27 Jun 2022 16:45:36 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500007.china.huawei.com (7.185.36.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 27 Jun 2022 16:45:36 +0800 From: Yang Yingliang To: , , CC: , , Subject: [PATCH -next] iommu/dma: Fix missing mutex_init() in iommu_get_msi_cookie() Date: Mon, 27 Jun 2022 16:55:33 +0800 Message-ID: <20220627085533.1469141-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500007.china.huawei.com (7.185.36.183) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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_ini= t() into cookie_alloc() to make sure the mutex will be initialized. Fixes: ac9a5d522bb8 ("iommu/dma: Fix race condition during iova_domain init= ialization") 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 =3D 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; =20 - mutex_init(&domain->iova_cookie->mutex); return 0; } =20 --=20 2.25.1