Skip to content

Commit 5566174

Browse files
rmurphy-armthierryreding
authored andcommitted
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: 20e7dce ("drm/tegra: Remove memory allocation from Falcon library") CC: Thierry Reding <[email protected]> CC: Mikko Perttunen <[email protected]> CC: [email protected] Signed-off-by: Robin Murphy <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Thierry Reding <[email protected]>
1 parent 20c5a61 commit 5566174

File tree

1 file changed

+3
-4
lines changed
  • drivers/gpu/drm/tegra

1 file changed

+3
-4
lines changed

drivers/gpu/drm/tegra/vic.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <linux/clk.h>
77
#include <linux/delay.h>
8+
#include <linux/dma-mapping.h>
89
#include <linux/host1x.h>
910
#include <linux/iommu.h>
1011
#include <linux/module.h>
@@ -232,10 +233,8 @@ static int vic_load_firmware(struct vic *vic)
232233

233234
if (!client->group) {
234235
virt = dma_alloc_coherent(vic->dev, size, &iova, GFP_KERNEL);
235-
236-
err = dma_mapping_error(vic->dev, iova);
237-
if (err < 0)
238-
return err;
236+
if (!virt)
237+
return -ENOMEM;
239238
} else {
240239
virt = tegra_drm_alloc(tegra, size, &iova);
241240
}

0 commit comments

Comments
 (0)