[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4uszly3pf2iddttdwbrfnt5pypzsyj4loz4i3a6ecnekkiedgr@r2bbpn6ymtax>
Date: Thu, 9 Oct 2025 12:15:57 +0200
From: Thierry Reding <thierry.reding@...il.com>
To: Johan Hovold <johan@...nel.org>
Cc: Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>,
Robin Murphy <robin.murphy@....com>, Sven Peter <sven@...nel.org>, Janne Grunau <j@...nau.net>,
Rob Clark <robin.clark@....qualcomm.com>, Marek Szyprowski <m.szyprowski@...sung.com>,
Yong Wu <yong.wu@...iatek.com>, Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>, Chen-Yu Tsai <wens@...e.org>, Krishna Reddy <vdumpa@...dia.com>,
iommu@...ts.linux.dev, linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Thierry Reding <treding@...dia.com>, Miaoqian Lin <linmq006@...il.com>
Subject: Re: [PATCH v2 14/14] iommu/tegra: fix device leak on probe_device()
On Thu, Oct 09, 2025 at 10:27:55AM +0200, Johan Hovold wrote:
> On Thu, Oct 09, 2025 at 09:56:18AM +0200, Thierry Reding wrote:
> > On Tue, Oct 07, 2025 at 11:43:27AM +0200, Johan Hovold wrote:
>
> > > @@ -830,10 +830,9 @@ static struct tegra_smmu *tegra_smmu_find(struct device_node *np)
> > > return NULL;
> > >
> > > mc = platform_get_drvdata(pdev);
> > > - if (!mc) {
> > > - put_device(&pdev->dev);
> > > + put_device(&pdev->dev);
> > > + if (!mc)
> > > return NULL;
> > > - }
> > >
> > > return mc->smmu;
> >
> > pdev->dev is what's backing mc, so if we use put_device() here, then the
> > MC could go away at any time, right?
>
> Holding a reference to a device does not prevent its driver data from
> going away so there is no point in keeping the reference.
>
> But from what I can tell, you don't need to worry about that anyway
> since it's the memory controller driver that registers the iommu (and
> the driver can't be unbound).
That's true. It'd be nice to at least conceptually do the right thing
here, but not sure it's worth it. As you said, driver data going away
would need special handling and it's not even clear what that would
mean in terms of the clients...
Acked-by: Thierry Reding <treding@...dia.com>
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists