From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCBADC433EF for ; Mon, 14 Feb 2022 12:49:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353483AbiBNMuA (ORCPT ); Mon, 14 Feb 2022 07:50:00 -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> 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.