Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5978363pxb; Mon, 14 Feb 2022 12:11:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDXr1uW6vxg3QVfcGWo2vzJ8/1mGFMY6Q7+XgyBOumFMJSn3wNsN7LI5O1zo11bt2Xm4G4 X-Received: by 2002:a17:90b:4d82:: with SMTP id oj2mr320423pjb.133.1644869479878; Mon, 14 Feb 2022 12:11:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644869479; cv=none; d=google.com; s=arc-20160816; b=F3VzVAmOijS91JfYgyQae7pVcMW2bLMhjHo2ahTE7CYONLUjeULxrAkl2qh84J2LA/ 525i656OhpCyRjGKMBfig2gsJoHw7EwlU9rCfl28wTPLp14sBCCWMhSH0/rgYQKzgW1M A82ALC9+rVZljoj7zsXnVnTXVrj75qih7ZYEdDhuLwnhUGzqQnF/ICr1UnRsbl399PFU jYNlveZq6naKM7qzFzDLEb79ZgEBUgzUEXnvz6j3uvkhnVflZRzu4islSdr6w05SGf0l CYo1dTbdPI2Qe+6bFnURZI5yG9coDvELtHrNBxMY9a0AciOXQYWVfqinDW8dRh8N6Z02 ggbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=3fCSoEqPX0dqqS/610ygGITeZbmQhsmbQkacxV9B0fE=; b=ndxyZSJmWuWmCyYfnAdHjO33+isd+N2kT+gfMDeytAZvDQfL19P+CvmSKwaMD1t21h 42kfs6JZsIEzpZSsJ6hLyZx+pByqOjp3LMkyaZQJkjsR3EnNIfvp/yZKdzic7zwJitIP 2r3yw6a/PlIENudBZP0V6ET8LfIjPEJneBumVRoAu877NHtCdNW9qwZG8pmQ21kDAsyd YAJYcBJef9khyxtJFG5xJTD5YoYWZoyGUBpjQnWPFyJmomp5smEe/rkvlhLmRSpwD/gP nhIxNqx8lOOb4VhKapRNO1mItr6RA9FK+UIZpA7uyTw4QkxAa/8pHsE3eVqvwJKDCWgR bmPA== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 12si662672pgb.18.2022.02.14.12.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:11:19 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1B6721617EE; Mon, 14 Feb 2022 11:48:25 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350550AbiBNMt7 (ORCPT + 99 others); Mon, 14 Feb 2022 07:49:59 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229978AbiBNMt6 (ORCPT ); Mon, 14 Feb 2022 07:49:58 -0500 Received: from theia.8bytes.org (8bytes.org [81.169.241.247]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81F144B846 for ; Mon, 14 Feb 2022 04:49:51 -0800 (PST) Received: by theia.8bytes.org (Postfix, from userid 1000) id C068B2FB; Mon, 14 Feb 2022 13:49:49 +0100 (CET) Date: Mon, 14 Feb 2022 13:49:48 +0100 From: Joerg Roedel To: Lu Baolu Cc: 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 Message-ID: References: <20220214015538.2828933-1-baolu.lu@linux.intel.com> <20220214015538.2828933-8-baolu.lu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220214015538.2828933-8-baolu.lu@linux.intel.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 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.