mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Johan Hovold <johan@kernel.org>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Sven Peter <sven@kernel.org>, Janne Grunau <j@jannau.net>,
	Rob Clark <robin.clark@oss.qualcomm.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Yong Wu <yong.wu@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Chen-Yu Tsai <wens@csie.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Krishna Reddy <vdumpa@nvidia.com>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 00/14] iommu: fix device leaks
Date: Tue, 30 Sep 2025 20:35:01 +0100	[thread overview]
Message-ID: <0d5d4d02-eb78-43dc-8784-83c0760099f7@arm.com> (raw)
In-Reply-To: <20250930182158.GS2695987@ziepe.ca>

On 2025-09-30 7:21 pm, Jason Gunthorpe wrote:
> On Thu, Sep 25, 2025 at 02:27:42PM +0200, Johan Hovold wrote:
>> This series fixes device leaks in the iommu drivers, which pretty
>> consistently failed to drop the reference taken by
>> of_find_device_by_node() when looking up iommu platform devices.
> 
> Yes, they are mis-designed in many ways :\

Historically they weren't really leaks either, just spare references on 
a device which at that point could definitely never go away. I suppose 
now that we finally have the .of_xlate calls in IOMMU registration, it 
would be possible for some error during probe to cause the IOMMU driver 
to fail to bind, at which point the references could rightly be 
considered leaked, however these are all embedded platforms with 
essentially zero chance of platform device hotplug, especially not of 
IOMMU devices, so realistically those references still don't matter to 
anything other than code checkers.

In summary; meh.
> IDK if it is worth fixing like this, or if more effort should be put
> to make the drivers use of_xlate properly - the arm smmu drivers show
> the only way to use it..

The SMMU drivers are really doing the same thing, they just defer that 
lookup operation to .probe_device time (largely for historical reasons, 
I think), and they use bus_find_device_by_node() rather than the 
specific of_ version since they support ACPI too. And they do happen to 
include the put_device(), since apparently I was paying full attention 
that day.

> But if staying like this then maybe add a little helper?
> 
> void *iommu_xlate_to_iommu_drvdata(const struct of_phandle_args *args);
> 
> Put the whole racy of_find_device_by_node / put_device /
> platform_get_drvdata sequence is in one tidy function.. With
> documentation it is not safe don't use it in new code?

It's not racy; if we're calling the .of_xlate op (or really any op for 
that matter), it's because an IOMMU driver has registered (or is 
registering) for the given fwnode, which means it is bound to the 
corresponding struct device. Thus as above, in that context said struct 
device, nor said IOMMU driver's drvdata, ain't goin' nowhere.

Thanks,
Robin.

  reply	other threads:[~2025-09-30 19:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-25 12:27 Johan Hovold
2025-09-25 12:27 ` [PATCH 01/14] iommu/apple-dart: fix device leak on of_xlate() Johan Hovold
2025-09-25 12:27 ` [PATCH 02/14] iommu/qcom: " Johan Hovold
2025-09-25 12:27 ` [PATCH 03/14] iommu/exynos: " Johan Hovold
2025-09-25 12:27 ` [PATCH 04/14] iommu/ipmmu-vmsa: " Johan Hovold
2025-09-25 12:27 ` [PATCH 05/14] iommu/mediatek: " Johan Hovold
2025-09-25 12:27 ` [PATCH 06/14] iommu/mediatek: fix device leaks on probe() Johan Hovold
2025-09-25 12:27 ` [PATCH 07/14] iommu/mediatek: simplify dt parsing error handling Johan Hovold
2025-09-25 12:27 ` [PATCH 08/14] iommu/mediatek-v1: fix device leak on probe_device() Johan Hovold
2025-09-25 12:27 ` [PATCH 09/14] iommu/mediatek-v1: fix device leaks on probe() Johan Hovold
2025-09-25 12:27 ` [PATCH 10/14] iommu/mediatek-v1: add missing larb count sanity check Johan Hovold
2025-09-25 12:27 ` [PATCH 11/14] iommu/omap: fix device leaks on probe_device() Johan Hovold
2025-10-02 12:05   ` Robin Murphy
2025-10-02 14:45     ` Johan Hovold
2025-09-25 12:27 ` [PATCH 12/14] iommu/omap: simplify probe_device() error handling Johan Hovold
2025-09-25 12:27 ` [PATCH 13/14] iommu/sun50i: fix device leak on of_xlate() Johan Hovold
2025-09-25 12:27 ` [PATCH 14/14] iommu/tegra: fix device leak on probe_device() Johan Hovold
2025-09-30 18:21 ` [PATCH 00/14] iommu: fix device leaks Jason Gunthorpe
2025-09-30 19:35   ` Robin Murphy [this message]
2025-10-01 15:58     ` Jason Gunthorpe
2025-10-02 11:48       ` Robin Murphy
2025-10-02 13:01         ` Jason Gunthorpe
2025-10-01  9:16   ` Johan Hovold
2025-10-01 16:01     ` Jason Gunthorpe
2025-10-07  9:41       ` Johan Hovold
2025-10-02 12:17 ` Robin Murphy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0d5d4d02-eb78-43dc-8784-83c0760099f7@arm.com \
    --to=robin.murphy@arm.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=iommu@lists.linux.dev \
    --cc=j@jannau.net \
    --cc=jgg@ziepe.ca \
    --cc=johan@kernel.org \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=matthias.bgg@gmail.com \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=sven@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=vdumpa@nvidia.com \
    --cc=wens@csie.org \
    --cc=will@kernel.org \
    --cc=yong.wu@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®