Skip to content

Commit da5d274

Browse files
committed
iommu/mediatek: Use correct fwspec in mtk_iommu_add_device()
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: a9bf2ee ('iommu/mediatek: Use helper functions to access dev->iommu_fwspec') Tested-by: Frank Wunderlich <frank-w@public-files.de> Signed-off-by: Joerg Roedel <jroedel@suse.de>
1 parent 198bc32 commit da5d274

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/iommu/mtk_iommu_v1.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@ static int mtk_iommu_add_device(struct device *dev)
442442
iommu_spec.args_count = count;
443443

444444
mtk_iommu_create_mapping(dev, &iommu_spec);
445+
446+
/* dev->iommu_fwspec might have changed */
447+
fwspec = dev_iommu_fwspec_get(dev);
448+
445449
of_node_put(iommu_spec.np);
446450
}
447451

0 commit comments

Comments
 (0)