From: Thierry Reding Date: Thu, 6 Nov 2014 13:41:31 +0000 (+0100) Subject: drm/tegra: gem: Check before freeing CMA memory X-Git-Tag: MMI-PSA29.97-13-9~10979^2~61^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7e0180e3570cc791e95e6b6cd5fbeb0aedc62776;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git drm/tegra: gem: Check before freeing CMA memory dma_free_writecombine() must not be called on a buffer that couldn't be allocated. Check for a valid virtual address before attempting to free the memory to avoid a crash. Reported-by: Sean Paul Reviewed-by: Sean Paul Signed-off-by: Thierry Reding --- diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c index 4a4f967c6397..da32086cbeaf 100644 --- a/drivers/gpu/drm/tegra/gem.c +++ b/drivers/gpu/drm/tegra/gem.c @@ -210,7 +210,7 @@ static void tegra_bo_free(struct drm_device *drm, struct tegra_bo *bo) drm_gem_put_pages(&bo->gem, bo->pages, true, true); sg_free_table(bo->sgt); kfree(bo->sgt); - } else { + } else if (bo->vaddr) { dma_free_writecombine(drm->dev, bo->gem.size, bo->vaddr, bo->paddr); }