Skip to content

Commit

Permalink
iommu/mediatek: Use correct fwspec in mtk_iommu_add_device()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Joerg Roedel committed Jan 23, 2019
1 parent 198bc32 commit da5d274
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/iommu/mtk_iommu_v1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit da5d274

Please sign in to comment.