[PATCH] drm/prime: fix sgt NULL checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Change-Id: I3b2f5878dfac6e1e77aebeeb7be781113dec59a7
Signed-off-by: Joonyoung Shim <jy0922.shim@xxxxxxxxxxx>
---
 drivers/gpu/drm/drm_prime.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 1e0de41..ff5fece 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -119,12 +119,13 @@ static void drm_gem_map_detach(struct dma_buf *dma_buf,
 		return;
 
 	sgt = prime_attach->sgt;
+	if (sgt) {
+		if (prime_attach->dir != DMA_NONE)
+			dma_unmap_sg(attach->dev, sgt->sgl, sgt->nents,
+					prime_attach->dir);
+		sg_free_table(sgt);
+	}
 
-	if (prime_attach->dir != DMA_NONE)
-		dma_unmap_sg(attach->dev, sgt->sgl, sgt->nents,
-				prime_attach->dir);
-
-	sg_free_table(sgt);
 	kfree(sgt);
 	kfree(prime_attach);
 	attach->priv = NULL;
-- 
1.8.1.2

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux