tbm_drm_helper: fix Svace UNCHECKED_FUNC_RES defect 00/132400/2
authorYoungJun Cho <yj44.cho@samsung.com>
Mon, 5 Jun 2017 01:40:42 +0000 (10:40 +0900)
committerYoungJun Cho <yj44.cho@samsung.com>
Mon, 5 Jun 2017 01:51:33 +0000 (10:51 +0900)
This patch fixies Svace UNCHECKED_FUNC_RES defect.

Change-Id: Ie0e3b8a15ed8d0669a108b9c4fb156a8c233d2d1
Signed-off-by: YoungJun Cho <yj44.cho@samsung.com>
src/tbm_drm_helper_client.c
src/tbm_drm_helper_server.c

index 6611d64..10828be 100644 (file)
@@ -268,7 +268,11 @@ tbm_drm_helper_get_fd(void)
                return -1;
        }
 
-       fcntl(new_fd, F_SETFD, flags|FD_CLOEXEC);
+       if (fcntl(new_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
+               TBM_LOG_E("failed to set fd\n");
+               close(new_fd);
+               return -1;
+       }
 
        TBM_LOG_I("Return TBM_FD: %d\n", new_fd);
 
index 7881d66..baa18d1 100644 (file)
@@ -66,8 +66,12 @@ _send_server_auth_info(struct wayland_tbm_drm_auth_server *tbm_drm_auth_srv,
        fd = open(tbm_drm_auth_srv->device_name, O_RDWR | O_CLOEXEC);
        if (fd == -1 && errno == EINVAL) {
                fd = open(tbm_drm_auth_srv->device_name, O_RDWR);
-               if (fd != -1)
-                       fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
+               if (fd != -1) {
+                       if (fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC) == -1) {
+                               TBM_LOG_E("failed to set fd\n");
+                               goto fini;
+                       }
+               }
        }
 
        if (fd < 0) {
@@ -342,7 +346,11 @@ tbm_drm_helper_get_master_fd(void)
                return -1;
        }
 
-       fcntl(new_fd, F_SETFD, flags|FD_CLOEXEC);
+       if (fcntl(new_fd, F_SETFD, flags|FD_CLOEXEC) == -1) {
+               TBM_LOG_E("failed to set fd\n");
+               close(new_fd);
+               return -1;
+       }
 
        TBM_LOG_I("Return MASTER_FD: %d\n", new_fd);