[PATCH libdrm] freedreno: zero is a valid fd number, treat it as such

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

 



Abeit quite unlikely to get hit by this bug here, let just fix it.

Cc: freedreno@xxxxxxxxxxxxxxxxxxxxx
Cc: Rob Clark <robdclark@xxxxxxxxx>
Signed-off-by: Emil Velikov <emil.l.velikov@xxxxxxxxx>
---
 freedreno/freedreno_bo.c | 6 +++---
 freedreno/kgsl/kgsl_bo.c | 1 +
 freedreno/msm/msm_bo.c   | 1 +
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/freedreno/freedreno_bo.c b/freedreno/freedreno_bo.c
index 517a2f8..ffaef4c 100644
--- a/freedreno/freedreno_bo.c
+++ b/freedreno/freedreno_bo.c
@@ -285,9 +285,9 @@ void fd_bo_del(struct fd_bo *bo)
 	if (!atomic_dec_and_test(&bo->refcnt))
 		return;
 
-	if (bo->fd) {
+	if (bo->fd >= 0) {
 		close(bo->fd);
-		bo->fd = 0;
+		bo->fd = -1;
 	}
 
 	pthread_mutex_lock(&table_lock);
@@ -372,7 +372,7 @@ uint32_t fd_bo_handle(struct fd_bo *bo)
 
 int fd_bo_dmabuf(struct fd_bo *bo)
 {
-	if (!bo->fd) {
+	if (bo->fd >= 0) {
 		struct drm_prime_handle req = {
 				.handle = bo->handle,
 				.flags = DRM_CLOEXEC,
diff --git a/freedreno/kgsl/kgsl_bo.c b/freedreno/kgsl/kgsl_bo.c
index 15c3ff5..3407c76 100644
--- a/freedreno/kgsl/kgsl_bo.c
+++ b/freedreno/kgsl/kgsl_bo.c
@@ -168,6 +168,7 @@ drm_private struct fd_bo * kgsl_bo_from_handle(struct fd_device *dev,
 
 	bo = &kgsl_bo->base;
 	bo->funcs = &funcs;
+	bo->fd = -1;
 
 	for (i = 0; i < ARRAY_SIZE(kgsl_bo->list); i++)
 		list_inithead(&kgsl_bo->list[i]);
diff --git a/freedreno/msm/msm_bo.c b/freedreno/msm/msm_bo.c
index fbd82df..3f5b6d0 100644
--- a/freedreno/msm/msm_bo.c
+++ b/freedreno/msm/msm_bo.c
@@ -137,6 +137,7 @@ drm_private struct fd_bo * msm_bo_from_handle(struct fd_device *dev,
 
 	bo = &msm_bo->base;
 	bo->funcs = &funcs;
+	bo->fd = -1;
 
 	for (i = 0; i < ARRAY_SIZE(msm_bo->list); i++)
 		list_inithead(&msm_bo->list[i]);
-- 
2.4.5

_______________________________________________
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