[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_22664B08ACDCE35DE10E5546C2FB26B59605@qq.com>
Date: Sun, 13 Jul 2025 00:16:24 +0800
From: Zhang Shurong <zhang_shurong@...mail.com>
To: sven@...nel.org
Cc: j@...nau.net,
alyssa@...enzweig.io,
neal@...pa.dev,
joro@...tes.org,
will@...nel.org,
robin.murphy@....com,
asahi@...ts.linux.dev,
linux-arm-kernel@...ts.infradead.org,
iommu@...ts.linux.dev,
linux-kernel@...r.kernel.org,
Zhang Shurong <zhang_shurong@...mail.com>
Subject: [PATCH] iommu/dart: add missing put_device() call in apple_dart_of_xlate
The apple_dart_of_xlate() function obtains a platform device reference
via of_find_device_by_node() but doesn't release it with put_device().
This patch adds proper device reference handling to prevent memory
leaks.
Fixes: 46d1fb072e76 ("iommu/dart: Add DART iommu driver")
Signed-off-by: Zhang Shurong <zhang_shurong@...mail.com>
---
drivers/iommu/apple-dart.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c
index 190f28d76615..811bf5176568 100644
--- a/drivers/iommu/apple-dart.c
+++ b/drivers/iommu/apple-dart.c
@@ -796,8 +796,10 @@ static int apple_dart_of_xlate(struct device *dev,
if (!cfg) {
cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
- if (!cfg)
+ if (!cfg) {
+ put_device(&iommu_pdev->dev);
return -ENOMEM;
+ }
/* Will be ANDed with DART capabilities */
cfg->supports_bypass = true;
}
@@ -805,8 +807,10 @@ static int apple_dart_of_xlate(struct device *dev,
cfg_dart = cfg->stream_maps[0].dart;
if (cfg_dart) {
- if (cfg_dart->pgsize != dart->pgsize)
+ if (cfg_dart->pgsize != dart->pgsize) {
+ put_device(&iommu_pdev->dev);
return -EINVAL;
+ }
}
cfg->supports_bypass &= dart->supports_bypass;
@@ -825,6 +829,8 @@ static int apple_dart_of_xlate(struct device *dev,
}
}
+
+ put_device(&iommu_pdev->dev);
return -EINVAL;
}
--
2.39.5
Powered by blists - more mailing lists