Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6278336pxb; Mon, 14 Feb 2022 21:25:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBnk0hhX58/Y4h7Z2b7qTepSWSbKf8lnp8jrX6cMnlb5eM47R5ty+dHJAoYOHimJ5OZjc7 X-Received: by 2002:a17:907:7f02:: with SMTP id qf2mr1632362ejc.513.1644902734348; Mon, 14 Feb 2022 21:25:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644902734; cv=none; d=google.com; s=arc-20160816; b=Gxu+4bhqJxnWg787KlJZn86R294eNh8Lg9uLn4QhFP5D9uh2yEbFuxQ31Dqrs+twLs TKQx63R6TviI5X/ttdaJi/AHPiTINIw0uLbUppr36fN/eC3mwg3kKVRjGBjXPKpxTHph oQF9XWH3WOhKTkWea/9a9ip22EJSmSpQnmKNmhTvDDvAuJOz0K6HNTHeVLqnBqKdPdoS DlHg5bUExpuUyTJ88gaK8RCSfxE1vXhWV0lHp940o/u3RlkoVR5gyf+lEufuvN/NmXy7 jzEbiKgy/GjHrPmR04rZmn8S3YXtbZ6WxGhaHndCfE41KzT207l9uaNDhkbBl9ICyrac l2Xw== 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=XafXtMYzWJ2LjwE6ozbrjRsV3YYvOLZjEEcJMfzec+I=; b=xOUbVfFWmcLEU2Jso0uj7T4u0R/DpWJtb7qQUlSWkTByDypavpDj1I3NMx7Tat2+hj /pQy0WRF66VlKYUlwaK43GYe/Jp4i1e7T7zbRuqyL/IJzsXNUa1szSTV4pNuiZFHUmQ6 WrSynguObJggsiEO2lXG2cimbI1PbNmez5Esy+YxcaQfBzEoUdQXwdiExhxz3jvrozye 3auqgWgPDFIYBejSY3pBPSu6b1Xksts+0ru/hPg4rOVOSqD5GqGE7zXcROkUjHK/P9Yp pxYE9iURL10b//gbwxI56QHfsIepgjhV9qNHQxvyWFZUB7B3QYyxFhW8Xy5ZQTuaaP4u zFYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Ba+t9a4/"; 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 cr21si22902983ejc.46.2022.02.14.21.25.11; Mon, 14 Feb 2022 21:25:34 -0800 (PST) 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="Ba+t9a4/"; 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 S233320AbiBOCDb (ORCPT + 99 others); Mon, 14 Feb 2022 21:03:31 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233287AbiBOCDU (ORCPT ); Mon, 14 Feb 2022 21:03:20 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD92A108754 for ; Mon, 14 Feb 2022 18:02:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1644890567; x=1676426567; h=message-id:date:mime-version:cc:subject:to:references: from:in-reply-to:content-transfer-encoding; bh=PQx1bi+RZ7llbsZzitox0+KHCY/gJAuQuxLD+34SPaA=; b=Ba+t9a4/llBJ743bF5dFLheLd7Cv7IfFQn14tpLY/7RAJyPDaEEdokIn 46B7DGf3zPf2zH0kHgRXkoses91VmoI6vW8RNXceBdbq0EeFATROXJue9 UTOIno2fihcQuPTdXB2LQkTfiSdfhLfTvxAIVnUWX3XSfEwdAlzSkRxf5 zlyflQFoNBtn8676++uNckpTWvflIxSQ2ZwZKkmcUItLdV5PCs5LoQ5Xh fMfd7snq6q0aIfHVUfZi4Pu47khq1+7sctlRpXRt6SFa2CAuQ0a547Vcj tQ2zcw6vgoE2wwRd5acNCBYw3Zi3uDtzuYVi5K0lX0ntGgL2SqBZulSBn w==; X-IronPort-AV: E=McAfee;i="6200,9189,10258"; a="250435769" X-IronPort-AV: E=Sophos;i="5.88,369,1635231600"; d="scan'208";a="250435769" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2022 18:02:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,369,1635231600"; d="scan'208";a="680793619" Received: from allen-box.sh.intel.com (HELO [10.239.159.118]) ([10.239.159.118]) by fmsmga001.fm.intel.com with ESMTP; 14 Feb 2022 18:02:43 -0800 Message-ID: <0bf678af-1905-de87-322b-43703992030b@linux.intel.com> Date: Tue, 15 Feb 2022 10:01:24 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Cc: baolu.lu@linux.intel.com, Jason Gunthorpe , Christoph Hellwig , Ben Skeggs , Kevin Tian , Ashok Raj , Will Deacon , Robin Murphy , Alex Williamson , Eric Auger , Liu Yi L , Jacob jun Pan , David Airlie , Daniel Vetter , Thierry Reding , Jonathan Hunter , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Christoph Hellwig Subject: Re: [PATCH v3 07/10] iommu: Use right way to retrieve iommu_ops Content-Language: en-US To: Joerg Roedel References: <20220214015538.2828933-1-baolu.lu@linux.intel.com> <20220214015538.2828933-8-baolu.lu@linux.intel.com> <0dd0f4c9-37a6-0418-3f19-22c40ccc8265@linux.intel.com> From: Lu Baolu In-Reply-To: <0dd0f4c9-37a6-0418-3f19-22c40ccc8265@linux.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, 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 On 2/15/22 9:46 AM, Lu Baolu wrote: > On 2/14/22 8:49 PM, Joerg Roedel wrote: >> On Mon, Feb 14, 2022 at 09:55:35AM +0800, Lu Baolu wrote: >>> +static inline const struct iommu_ops *dev_iommu_ops(struct device *dev) >>> +{ >>> +    /* >>> +     * Assume that valid ops must be installed if iommu_probe_device() >>> +     * has succeeded. The device ops are essentially for internal use >>> +     * within the IOMMU subsystem itself, so we should be able to trust >>> +     * ourselves not to misuse the helper. >>> +     */ >>> +    WARN_ON(!dev || !dev->iommu || !dev->iommu->iommu_dev || >>> +        !dev->iommu->iommu_dev->ops); >> >> There is no need for this WARN_ON, the code will oops anyway when one of >> the pointers checked here is NULL. >> > > We really don't need to WARN_ON intermediate null pointers. But I would > argue that we could add a WARN() on null dev->iommu->iommu_dev->ops, so > that callers have no need to check the returned ops. Oh, sorry! We don't need to check null ops either. That will also result in a null pointer reference oops in the caller. So, yes. No need for this WARN_ON(). Best regards, baolu