add type casting for size vaule and fix handle leak
[platform/adaptation/spreadtrum/libtbm-sprd.git] / src / tbm_bufmgr_sprd.c
index 63b0eb6..f14aab2 100755 (executable)
@@ -367,6 +367,7 @@ _tgl_get_data(int fd, unsigned int key, unsigned int *locked)
        return arg.data1;
 }
 
+#if 0
 static int
 _tbm_sprd_open_drm()
 {
@@ -458,6 +459,7 @@ _tbm_sprd_open_drm()
 
        return fd;
 }
+#endif
 
 static int
 _sprd_bo_cache_flush (tbm_bo bo, int flags)
@@ -832,7 +834,7 @@ tbm_sprd_bo_alloc (tbm_bo bo, int size, int flags)
        }
 #endif // USE_CONTIG_ONLY
        struct drm_sprd_gem_create arg = {0, };
-       arg.size = size;
+       arg.size = (uint64_t)size;
        arg.flags = sprd_flags;
        if (drmCommandWriteRead(bufmgr_sprd->fd, DRM_SPRD_GEM_CREATE, &arg,
                                sizeof(arg))) {
@@ -1860,6 +1862,8 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd)
        }
 
        if (tbm_backend_is_display_server()) {
+#if 0
+               /* this code is applied with libtdm-sprd */
                int master_fd = -1;
 
                bufmgr_sprd->fd = -1;
@@ -1870,6 +1874,9 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd)
                } else {
                        bufmgr_sprd->fd = dup(master_fd);
                }
+#else
+               bufmgr_sprd->fd = dup(fd);
+#endif
 
                if (bufmgr_sprd->fd < 0) {
                        TBM_SPRD_LOG ("[libtbm-sprd:%d] error: Fail to create drm!\n", getpid());
@@ -1882,6 +1889,7 @@ init_tbm_bufmgr_priv (tbm_bufmgr bufmgr, int fd)
                if (!bufmgr_sprd->device_name)
                {
                        TBM_SPRD_LOG ("[libtbm-sprd:%d] error: Fail to get device name!\n", getpid());
+                       close(bufmgr_sprd->fd);
                        free (bufmgr_sprd);
                        return 0;
                }