From patchwork Tue May 30 09:25:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yanfei Xu X-Patchwork-Id: 100700 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2055828vqr; Tue, 30 May 2023 02:47:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ72rgF/72lkvh+UzyNZQdT5ik1RJ+hgqTvQgkP6DP5mWvnVdK6whnyuIRpNUQ65vAUNvUpj X-Received: by 2002:a05:6a00:2387:b0:62d:cfd4:e440 with SMTP id f7-20020a056a00238700b0062dcfd4e440mr1935665pfc.8.1685440035724; Tue, 30 May 2023 02:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685440035; cv=none; d=google.com; s=arc-20160816; b=IMqoQ4nG7evE2VfXwx5SA5QuQcYrH/hDDDKyxfV4CtF/ootIykLoVDSiWMK/ey/AN1 RjWBG3/qVqhgGDsMvtmbkuKtxPKN7VDSVScB2h5FdchP6s9YgGqlEntOKdRnhTPVq6WJ 8dHeMeD9GIGSOjYQj24eKXqwyhgw0xjlmcjt9Jla29H4VjfdNs++HE3rXQn+Bjbk62Tu DIo92w770LwgFbz+0gtaDDaoueKtsOM2pMJNLt1ozhvFzGRY48dAPBLUpeVg1H5Zegac HQbCGeUzQ6g6hF5jYrK62we89hwAlwsLqgw5EHnWRLH6tgxLphTL9AdgnmvdQZFdC+Zi oQwQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WBIxYnT0TEn4xopQy+TwTuyRVDnVEx2DogYEE/Wwpwo=; b=zGQ2huODVEDD5v5PcP5i3xweT2QOAPu1nODgLf1Pda5t2C2n7UGaBuVKqT6rE770Fh at5NIRmfvhOEh+dIQm9mvVJ5CZByLLhZnqnYiLPKSf09N8pws5V9ruvEZNoDfDGpA6uD jyqV7gyEij2ypN5Tt5SMugPbwbj4XjRw6HDnOA2OMjhAZ1iwvnuHLQ+NUw8wcTDukdXw RcWjnztbGDAzE3nzb1EfIPXdoW7swpvfcdsmVVSkw0ThlyYV9viPtVFbQgxEURX53SmE uPlKP90PoZxEyq7gNJIHWUZA4A32P9tWxEQ0lHg9DRLsa80NUF2o3bPGhWSLAX9iPuGp VDFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=U+sUkeVR; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k24-20020aa79738000000b0063b54679d0dsi1517412pfg.44.2023.05.30.02.47.04; Tue, 30 May 2023 02:47:15 -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=U+sUkeVR; 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 S231175AbjE3J26 (ORCPT + 99 others); Tue, 30 May 2023 05:28:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbjE3J23 (ORCPT ); Tue, 30 May 2023 05:28:29 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11E23E47 for ; Tue, 30 May 2023 02:27:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685438870; x=1716974870; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bb/2NSh0FsupKWJ63NAi7JNkLNuSTtTj++ZJQlgFfKg=; b=U+sUkeVR+24sL4egl41ZbcONBQu0u+siT6qx1MBBfsU0C3Y07AvKvxoE mCNiQHz7FKxteHHonUFn5+M+th+UpBVGtMXY0grE/24lg2KN0ld/vnTFY QUGGcuVCYOPOm0SdvW+RgOqm6Qvrj2fwHq8MHbflCEZSCWCAILkgtJKbS OHR27AtdmkZUR4AWD+5Dh202q2caD8IZSzaOodPHkTKMCZa5kL/E2yipZ ug/4+jowYivPnLrjhxSb9yxKJ0GzBEfmbwySpvSQEWhlFLomM2ujuwczG n3tCHgdSmAGQ7XVl93+/jGuzAfJk5mmxZHGy/Zv/sUrfvr388j7zAE5LA w==; X-IronPort-AV: E=McAfee;i="6600,9927,10725"; a="344365177" X-IronPort-AV: E=Sophos;i="6.00,203,1681196400"; d="scan'208";a="344365177" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 02:27:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10725"; a="818720180" X-IronPort-AV: E=Sophos;i="6.00,203,1681196400"; d="scan'208";a="818720180" Received: from tower.bj.intel.com ([10.238.157.62]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 May 2023 02:27:47 -0700 From: Yanfei Xu To: dwmw2@infradead.org, baolu.lu@linux.intel.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, yanfei.xu@intel.com Subject: [PATCH 2/2] iommu/vt-d: Use BUG_ON to check NULL value of 'table' Date: Tue, 30 May 2023 17:25:03 +0800 Message-Id: <20230530092503.152926-3-yanfei.xu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530092503.152926-1-yanfei.xu@intel.com> References: <20230530092503.152926-1-yanfei.xu@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767311970625198045?= X-GMAIL-MSGID: =?utf-8?q?1767311970625198045?= 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); /* Setup the PASID DIR pointer: */ pds = context_get_sm_pds(table);