Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/tegra: falcon: Fix error handling

The ->alloc() callback in struct falcon_ops returns an ERR_PTR()-encoded
error code on failure, so it needs to be properly checked for, otherwise
subsequent code may dereference an invalid pointer.

Signed-off-by: Thierry Reding <treding@nvidia.com>

+3 -3
+3 -3
drivers/gpu/drm/tegra/falcon.c
··· 141 141 /* allocate iova space for the firmware */ 142 142 falcon->firmware.vaddr = falcon->ops->alloc(falcon, firmware->size, 143 143 &falcon->firmware.paddr); 144 - if (!falcon->firmware.vaddr) { 145 - dev_err(falcon->dev, "dma memory mapping failed\n"); 146 - return -ENOMEM; 144 + if (IS_ERR(falcon->firmware.vaddr)) { 145 + dev_err(falcon->dev, "DMA memory mapping failed\n"); 146 + return PTR_ERR(falcon->firmware.vaddr); 147 147 } 148 148 149 149 /* copy firmware image into local area. this also ensures endianness */