drm/tegra: gem: Check before freeing CMA memory
authorThierry Reding <treding@nvidia.com>
Thu, 6 Nov 2014 13:41:31 +0000 (14:41 +0100)
committerThierry Reding <treding@nvidia.com>
Thu, 13 Nov 2014 15:18:34 +0000 (16:18 +0100)
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 <seanpaul@chromium.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/drm/tegra/gem.c

index 4a4f967c6397d5ea44151ed6b1094fbea5fceb76..da32086cbeaf28bbe0c0528eeeac4c0bb9fcb326 100644 (file)
@@ -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);
        }