@@ -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,
@@ -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]);
@@ -101,7 +101,7 @@ static void kgsl_pipe_destroy(struct fd_pipe *pipe)
if (kgsl_pipe->drawctxt_id)
ioctl(kgsl_pipe->fd, IOCTL_KGSL_DRAWCTXT_DESTROY, &req);
- if (kgsl_pipe->fd)
+ if (kgsl_pipe->fd >= 0)
close(kgsl_pipe->fd);
free(kgsl_pipe);
@@ -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]);