Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1648426iog; Sat, 25 Jun 2022 15:33:17 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sVzr4f55QiSl+iI469dRFV7dYBBtnMSKVuUUro1LcHqm49uaoFDtPvEQQ5R+JXEsYBws7R X-Received: by 2002:a17:907:c06:b0:701:eb60:ded with SMTP id ga6-20020a1709070c0600b00701eb600dedmr5790383ejc.178.1656196397185; Sat, 25 Jun 2022 15:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656196397; cv=none; d=google.com; s=arc-20160816; b=K3ZBaqlJYZVTmynVyJ2SfyLWdgJxKP0uSRJPU5GxW18/OIwhshweEm+9oaTM+oikFr iUlVxzKvNClbMekScV/UwLkZYw9KfULfJifouUqmKU7Dr/MqWA/g+3cRlXtQNVyH0dOs 0Q08CDZZLeKf0tKTifFdZE6ievL4bIre6c98DuNRupS8qUMn5KV9dXtirIQ0C25USwDy 1J3IrB404F+YJPmMwOOnwBRl70h2TWjCVnCjTIIkxHw3c+VlxX20vqa9kakXiqdbEpfu k1B26lgUwJODuS214qcc+sD55s6BN5VlMG0+1MNersAJRcLsaKp9Vr9X7lAw8ekOLLiQ 4rkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=EbUPVrACrb5JazdoYAtaL55Q+DwnisM87pnjpaJYU4A=; b=pppzwKwGUnumu8PXGm/o8cbPu2zy7yBbZ8zutRsayUBy8fCEQytAGboVcDreF7IN/u lfBUnY6FnADZ8qs04uovuhxIvDNUle8De0Oqme026ZYLn5oNRQ/TjN+X1LgI830qjpBz vHopQPiusK3MCrHrZGgaJ14PmFwJikjVkLF+dzngCbMR3nT40ckXSuUuaBnKQ1CU7qIu w6XEibcdhgGP8piLPEsLkI0+DoUkRabkRDeMm/ok/q1GqkWt+0EOQkts+1B0ZlLX7joP 7nCvNsSiQL7ii6hCg4CThP7PWIGrdXhDQS3LNXP3M6VM/WY1ufGtSoxW6c5SJ0HoV+MV 61Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YrF7FPxt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd21-20020a1709069b9500b00718bf77195dsi5009181ejc.489.2022.06.25.15.32.46; Sat, 25 Jun 2022 15:33:17 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YrF7FPxt; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233322AbiFYWNq (ORCPT + 99 others); Sat, 25 Jun 2022 18:13:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230246AbiFYWNp (ORCPT ); Sat, 25 Jun 2022 18:13:45 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A23EA12AC4 for ; Sat, 25 Jun 2022 15:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656195221; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EbUPVrACrb5JazdoYAtaL55Q+DwnisM87pnjpaJYU4A=; b=YrF7FPxtsJ9uF2tAGkZkj2Mqyr+HZmWLOvH/kJ93RzK7h6XVhRzrRQ0Tfcykkq6bO7ght8 DT2L+wjo3DhGjb97V6iA9W3oldrrjJwfVSXpPGYJWdMeaQADk2j6He3YMfbihN6hPS71Zt w0mQeb+yEX4HOSmofdyxDgO5fnEPrTw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-J8IwCBHWONOMi9ZOj-iueQ-1; Sat, 25 Jun 2022 18:13:37 -0400 X-MC-Unique: J8IwCBHWONOMi9ZOj-iueQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76CD3811E75; Sat, 25 Jun 2022 22:13:37 +0000 (UTC) Received: from cantor.redhat.com (unknown [10.2.16.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id B93731121314; Sat, 25 Jun 2022 22:13:36 +0000 (UTC) From: Jerry Snitselaar To: dmaengine@vger.kernel.org Cc: Vinod Koul , linux-kernel@vger.kernel.org, Dave Jiang , Fenghua Yu Subject: [PATCH] dmaengine: idxd: Only call idxd_enable_system_pasid if succeeded in enabling SVA feature Date: Sat, 25 Jun 2022 15:13:33 -0700 Message-Id: <20220625221333.214589-1-jsnitsel@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,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 iommu_sva_bind_device requires that iommu_dev_enable_feature has been previously called with IOMMU_DEV_FEAT_SVA, and succeeded. Without this it is possible to run into a situation where you will dereference a null pointer if the intel_iommu driver is not enabled. Note: checkpatch didn't like the suggested addition of braces for the first arm of the "if (idxd_enable_system_pasid)" block. Fixes: 42a1b73852c4 ("dmaengine: idxd: Separate user and kernel pasid enabling") Cc: Vinod Koul Cc: linux-kernel@vger.kernel.org Cc: Dave Jiang Cc: Fenghua Yu Signed-off-by: Jerry Snitselaar --- drivers/dma/idxd/init.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c index 355fb3ef4cbf..5b49fd5c1e25 100644 --- a/drivers/dma/idxd/init.c +++ b/drivers/dma/idxd/init.c @@ -514,13 +514,14 @@ static int idxd_probe(struct idxd_device *idxd) if (IS_ENABLED(CONFIG_INTEL_IDXD_SVM) && sva) { if (iommu_dev_enable_feature(dev, IOMMU_DEV_FEAT_SVA)) dev_warn(dev, "Unable to turn on user SVA feature.\n"); - else + else { set_bit(IDXD_FLAG_USER_PASID_ENABLED, &idxd->flags); - if (idxd_enable_system_pasid(idxd)) - dev_warn(dev, "No in-kernel DMA with PASID.\n"); - else - set_bit(IDXD_FLAG_PASID_ENABLED, &idxd->flags); + if (idxd_enable_system_pasid(idxd)) + dev_warn(dev, "No in-kernel DMA with PASID.\n"); + else + set_bit(IDXD_FLAG_PASID_ENABLED, &idxd->flags); + } } else if (!sva) { dev_warn(dev, "User forced SVA off via module param.\n"); } -- 2.36.1