Re: [PATCH v2 03/11] drm/tegra: vic: Fix DMA API misuse
On Fri, Dec 10, 2021 at 05:54:44PM +, Robin Murphy wrote: > Upon failure, dma_alloc_coherent() returns NULL. If that does happen, > passing some uninitialised stack contents to dma_mapping_error() - which > belongs to a different API in the first place - has precious little > chance of detecting it. > > Also include the correct header, because the fragile transitive > inclusion currently providing it is going to break soon. > > Fixes: 20e7dce255e9 ("drm/tegra: Remove memory allocation from Falcon > library") > CC: Thierry Reding > CC: Mikko Perttunen > CC: dri-de...@lists.freedesktop.org > Signed-off-by: Robin Murphy > > --- > > It also doesn't appear to handle failure of the tegra_drm_alloc() path > either, but that's a loose thread I have no desire to pull on... ;) > > v2: Resend as part of the series, originally posted separately here: > > https://lore.kernel.org/dri-devel/2703882439344010e33bf21ecd63cf9e5e6dc00d.1637781007.git.robin.mur...@arm.com/ > > drivers/gpu/drm/tegra/vic.c | 7 +++ > 1 file changed, 3 insertions(+), 4 deletions(-) Applied, thanks. I've also fixed up the missing failure handling for tegra_drm_alloc(), which was actually quite trivial to do. Thierry signature.asc Description: PGP signature ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
Re: [PATCH v2 03/11] drm/tegra: vic: Fix DMA API misuse
Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
[PATCH v2 03/11] drm/tegra: vic: Fix DMA API misuse
Upon failure, dma_alloc_coherent() returns NULL. If that does happen, passing some uninitialised stack contents to dma_mapping_error() - which belongs to a different API in the first place - has precious little chance of detecting it. Also include the correct header, because the fragile transitive inclusion currently providing it is going to break soon. Fixes: 20e7dce255e9 ("drm/tegra: Remove memory allocation from Falcon library") CC: Thierry Reding CC: Mikko Perttunen CC: dri-de...@lists.freedesktop.org Signed-off-by: Robin Murphy --- It also doesn't appear to handle failure of the tegra_drm_alloc() path either, but that's a loose thread I have no desire to pull on... ;) v2: Resend as part of the series, originally posted separately here: https://lore.kernel.org/dri-devel/2703882439344010e33bf21ecd63cf9e5e6dc00d.1637781007.git.robin.mur...@arm.com/ drivers/gpu/drm/tegra/vic.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/tegra/vic.c b/drivers/gpu/drm/tegra/vic.c index c02010ff2b7f..da4af5371991 100644 --- a/drivers/gpu/drm/tegra/vic.c +++ b/drivers/gpu/drm/tegra/vic.c @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -232,10 +233,8 @@ static int vic_load_firmware(struct vic *vic) if (!client->group) { virt = dma_alloc_coherent(vic->dev, size, , GFP_KERNEL); - - err = dma_mapping_error(vic->dev, iova); - if (err < 0) - return err; + if (!virt) + return -ENOMEM; } else { virt = tegra_drm_alloc(tegra, size, ); } -- 2.28.0.dirty ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu