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

drm/prime: fix sgt NULL checking

The drm_gem_map_detach() can be called with sgt is NULL.

Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>

authored by

Joonyoung Shim and committed by
Dave Airlie
f9d8a129 63eef600

+6 -5
+6 -5
drivers/gpu/drm/drm_prime.c
··· 119 119 return; 120 120 121 121 sgt = prime_attach->sgt; 122 + if (sgt) { 123 + if (prime_attach->dir != DMA_NONE) 124 + dma_unmap_sg(attach->dev, sgt->sgl, sgt->nents, 125 + prime_attach->dir); 126 + sg_free_table(sgt); 127 + } 122 128 123 - if (prime_attach->dir != DMA_NONE) 124 - dma_unmap_sg(attach->dev, sgt->sgl, sgt->nents, 125 - prime_attach->dir); 126 - 127 - sg_free_table(sgt); 128 129 kfree(sgt); 129 130 kfree(prime_attach); 130 131 attach->priv = NULL;