Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp295677rwd; Tue, 30 May 2023 20:53:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ITI9z/lSWbKQdxHIxPW1wLINcKDoXiPqV2pmUkWDLpr+nicRyZGlDSUSI6rgQOJpHxqd8 X-Received: by 2002:a9d:6188:0:b0:6ac:a839:4da3 with SMTP id g8-20020a9d6188000000b006aca8394da3mr858521otk.23.1685505187593; Tue, 30 May 2023 20:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685505187; cv=none; d=google.com; s=arc-20160816; b=o9dEznudoRNRHc39pMWxhig2AYurumurDNkSSM/mpyRjV/x8ORct+wcnyOab60Fs/o Wk3u0AYQJ1+dtHm2fqe4AoA+i3g/7dAITHXoaXYzdmfwBJsDeaShiBYyt6rc8jyoA9EY wJs6fz+LPVSogD3FoTfvhL/i2mkd/bj246FCGGOTOVxSlAkgv/scguG10pFGwBXUT+Ni VxaS8hdrnp7SZu07Z/MWg6oDPxiQdcR4MeIFsfSrC4WIuOaRWaw4UaMg1XT0a1hTHQJy o5C9ZCRyRc41Na4ekE0LZY+fGe+3x9j0T3p7Gmz5vkejFn7Mgrxkm4SM2UKVAH1u58RJ OYjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:to:content-language:subject:cc:user-agent:mime-version :date:message-id:dkim-signature; bh=zfLcmEHt7rEMuqgz6jvjlgkODWzLiijBbxFrdFb+ECo=; b=Pg611ereakHKVJjCODoZFxWos4a5G55ebH/Eu9dnWpNqxmyDn1XVKCtBzICkWTRewT e1MAm/3JKTWNu91GNG0i5adesHG9XkUPgUcSm/OldSVTtT6ZmYlOuG+xmwFmlUq6eDeM vG1mnmV+7Ro+okHrzcbpkA0MSG7Hd7N3ntKVUUV524XfKBqvDsIctJIesjQPFkL6xqRM 10G/v0aw1Tuonx/yTXpGyRRq4zCECHVZzcykhJhRHhDy8KGmMXDFMk4g58RNSReUK5F2 oJqg5y3qgyrwHlpcVUva2K3N4GuMmc4gLrUkUniOdyhTCsUXFhARDosKMA7DSavAqSXH 3bvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WAZEy6lq; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020aa79e4b000000b0064f4d57a5ffsi2731037pfq.388.2023.05.30.20.52.54; Tue, 30 May 2023 20:53:07 -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=@intel.com header.s=Intel header.b=WAZEy6lq; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234181AbjEaD3c (ORCPT + 99 others); Tue, 30 May 2023 23:29:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234070AbjEaD2e (ORCPT ); Tue, 30 May 2023 23:28:34 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5342119A for ; Tue, 30 May 2023 20:28:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685503708; x=1717039708; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=TYMzU74WAhBotOE3c77ui6pPmq/ocGmpdHVCBH4pbX4=; b=WAZEy6lqv2znn+7p+ZXnYekSC/VCcmAdL23eXG7aq+eN3YKZbq7Tx0H8 cfnsRpQrHiZVHIxPDgMWDRkUO7gCd8YHMosuD4aiO77Shf8G2MZhea92y E2K2fGAlDGtra2Wdma0kudBlpQm/jnjzBgDDIZplZN4Nj9zo62sD7oGD2 8c8xB16mWyLT0TLA6DQK9J0W8UvUltwqnocHWdpUrBu7ryf5OsfPZzWkp 5aunGpyz6wktnskR/D4R4Unv/sG9YEjqCi2HoUUI8Jrkh+LWQiN+QqSeg xjQkJGEznR+Fn9MNb7IehtWIumPOFDYD4yHiIgXryN+zx6lfJaVjjOEmP g==; X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="339715115" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="339715115" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 20:27:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10726"; a="831049681" X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="831049681" Received: from allen-box.sh.intel.com (HELO [10.239.159.127]) ([10.239.159.127]) by orsmga004.jf.intel.com with ESMTP; 30 May 2023 20:27:49 -0700 Message-ID: <3e75f9de-4c67-93aa-9fb4-28da9849dd48@linux.intel.com> Date: Wed, 31 May 2023 11:26:55 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Cc: baolu.lu@linux.intel.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] iommu/vt-d: Use BUG_ON to check NULL value of 'table' Content-Language: en-US To: Yanfei Xu , dwmw2@infradead.org, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com References: <20230530092503.152926-1-yanfei.xu@intel.com> <20230530092503.152926-3-yanfei.xu@intel.com> From: Baolu Lu In-Reply-To: <20230530092503.152926-3-yanfei.xu@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On 5/30/23 5:25 PM, Yanfei Xu wrote: > Checking NULL value of 'table' variable deserves a BUG_ON as the > following code will trigger a crash by dereferencing the NULL > 'table' pointer. Crash in advance with BUG_ON to avoid WARN_ON > plus NULL pointer dereferencing can simplify the crash log. > > Signed-off-by: Yanfei Xu > --- > drivers/iommu/intel/iommu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c > index e98f1b122b49..8aa3bfdb7f95 100644 > --- a/drivers/iommu/intel/iommu.c > +++ b/drivers/iommu/intel/iommu.c > @@ -1944,7 +1944,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain, > if (sm_supported(iommu)) { > unsigned long pds; > > - WARN_ON(!table); > + BUG_ON(!table); BUG_ON() is not recommended. Perhaps, if (!table) -ENODEV; ? Best regards, baolu