Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp543256ybk; Fri, 15 May 2020 07:24:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXS/PbNHuJVMUAf2ECdoUIF05MFZRIJJFAhH4ist1CTTX2IfZbJ+VKZGuwY7fzKM6Ot0M7 X-Received: by 2002:a17:906:35d0:: with SMTP id p16mr2917752ejb.77.1589552688608; Fri, 15 May 2020 07:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589552688; cv=none; d=google.com; s=arc-20160816; b=iobiEqnlDcpgB3nK0LROyoq8GKMDssht8rOewAoaXhAHZRoBtITweLvGxB5w7SZ3dI SUtscBAnOwh1IsH//WRf/NdTQKfoK9xTkNMVyQBTypQf027jJnRO5eiSGHw6bRnOdj7K 56Her1MafQiT7F+YJ783TdFkjT5LiCXyaxxd5oDBJzdj+OzMowlbHJS6K/EwtUAQAXmJ h5l2AnqOQBO3W5wFjGULhgy/sFh4Q0I2q7CdFrAAVitk3hirol5WoiuQo88oWivzfbOF OLkXiHOZ0Ur/TPMv7MM6lRbWub2KhuhPmCz5LVJv0Fcu8GoTB3p9pee9e2lol/89XO0u F9+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=AaKf71C6cjlyK/XfVCUaB9iWXg3NlcHgU9ZnhyiStwA=; b=nrYCNMUltvtrW4271GIh1F9Kpv6wELLhvL5gj2KC5UJE9Mj+6ZiDEHeGha7QA+K2/U mW/fVIp3LTykXBkNPiBFch/44JBz9zkcND5ueQDaa8dnFiE7q2dNzbC+5kEDjQpVeav8 C6ppoNHu19KfdfeMjtpd9BrvJTHP2VhjkrmgZ0yb6nDSW9z3HyWEBjnOweCsUQ93QK8M bxCH83Z1QF0x9eO4hNf+UMpdDRxwNg7syovAeMBQPa+G7XJqHdDLTiRhFFN4a35Pkigu DLLjZaMF4FoT4FihOB4qqAuAPoEhEnRpS3lJazRW21KXrwns5OLy5s/cjFLpU/iRMJPb fbOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z13si1284120eju.18.2020.05.15.07.24.25; Fri, 15 May 2020 07:24:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726189AbgEOOUv (ORCPT + 99 others); Fri, 15 May 2020 10:20:51 -0400 Received: from 8bytes.org ([81.169.241.247]:43486 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726140AbgEOOUv (ORCPT ); Fri, 15 May 2020 10:20:51 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id 792053C3; Fri, 15 May 2020 16:20:49 +0200 (CEST) Date: Fri, 15 May 2020 16:20:48 +0200 From: Joerg Roedel To: Lu Baolu Cc: iommu@lists.linux-foundation.org, jroedel@suse.de, linux-kernel@vger.kernel.org, Tom Murphy Subject: Re: [PATCH] iommu: Implement deferred domain attachment Message-ID: <20200515142047.GX18353@8bytes.org> References: <20200515094519.20338-1-joro@8bytes.org> <8ce93a10-2ce0-e5a0-88a0-5d21d7003c0f@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8ce93a10-2ce0-e5a0-88a0-5d21d7003c0f@linux.intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 15, 2020 at 09:51:03PM +0800, Lu Baolu wrote: > On 2020/5/15 17:45, Joerg Roedel wrote: > > struct iommu_domain *iommu_get_dma_domain(struct device *dev) > > { > > - return dev->iommu_group->default_domain; > > + struct iommu_domain *domain = dev->iommu_group->default_domain; > > + > > + if (__iommu_is_attach_deferred(domain, dev)) > > + __iommu_attach_device_no_defer(domain, dev); > > It seems that the return value needs to be checked. The default domain > is invalid if attach() failed. True, I looked at that, the callers can't handle returning NULL here, so I kept it this way for now. The outcome is that DMA will fail, but otherwise we'd see a NULL-ptr dereference really quickly after returning from that function. Bottom line: This needs to be cleaned up separatly. Regards, Joerg