linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/mediatek: Use correct fwspec in mtk_iommu_add_device()
@ 2019-01-23  7:53 Joerg Roedel
  2019-01-23 12:00 ` Frank Wunderlich
  0 siblings, 1 reply; 2+ messages in thread
From: Joerg Roedel @ 2019-01-23  7:53 UTC (permalink / raw)
  To: iommu
  Cc: Matthias Brugger, linux-arm-kernel, linux-mediatek, linux-kernel,
	Frank Wunderlich, Joerg Roedel

From: Joerg Roedel <jroedel@suse.de>

The mtk_iommu_add_device() function keeps the fwspec in an
on-stack pointer and calls mtk_iommu_create_mapping(), which
might change its source, dev->iommu_fwspec. This causes the
on-stack pointer to be obsoleted and the device
initialization to fail. Update the on-stack fwspec pointer
after mtk_iommu_create_mapping() has been called.

Reported-by: Frank Wunderlich <frank-w@public-files.de>
Fixes: a9bf2eec5a6f ('iommu/mediatek: Use helper functions to access dev->iommu_fwspec')
Signed-off-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/mtk_iommu_v1.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/iommu/mtk_iommu_v1.c b/drivers/iommu/mtk_iommu_v1.c
index 6ede4286b835..f60bdb85c4c0 100644
--- a/drivers/iommu/mtk_iommu_v1.c
+++ b/drivers/iommu/mtk_iommu_v1.c
@@ -442,6 +442,10 @@ static int mtk_iommu_add_device(struct device *dev)
 		iommu_spec.args_count = count;
 
 		mtk_iommu_create_mapping(dev, &iommu_spec);
+
+		/* dev->iommu_fwspec might have changed */
+		fwspec = dev_iommu_fwspec_get(dev);
+
 		of_node_put(iommu_spec.np);
 	}
 
-- 
2.13.7


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] iommu/mediatek: Use correct fwspec in mtk_iommu_add_device()
  2019-01-23  7:53 [PATCH] iommu/mediatek: Use correct fwspec in mtk_iommu_add_device() Joerg Roedel
@ 2019-01-23 12:00 ` Frank Wunderlich
  0 siblings, 0 replies; 2+ messages in thread
From: Frank Wunderlich @ 2019-01-23 12:00 UTC (permalink / raw)
  To: linux-mediatek, Joerg Roedel, iommu
  Cc: Joerg Roedel, linux-kernel, Matthias Brugger, linux-arm-kernel

Tested-by: Frank Wunderlich <frank-w@public-files.de>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-23 12:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-23  7:53 [PATCH] iommu/mediatek: Use correct fwspec in mtk_iommu_add_device() Joerg Roedel
2019-01-23 12:00 ` Frank Wunderlich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).