iris: handle os_dupfd_cloexec failure
authorMarcin Ślusarz <marcin.slusarz@intel.com>
Thu, 30 Jul 2020 12:29:56 +0000 (14:29 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 2 Sep 2020 15:08:01 +0000 (15:08 +0000)
Found by Coverity.

Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6126>

src/gallium/winsys/iris/drm/iris_drm_winsys.c

index 57954e4827387e59852bf756b1e8ca4fb86e8b50..a7a70283ef930a9346fbea00afc78480990c0241 100644 (file)
@@ -32,5 +32,8 @@ extern struct pipe_screen *iris_screen_create(int fd, const struct pipe_screen_c
 struct pipe_screen *
 iris_drm_screen_create(int fd, const struct pipe_screen_config *config)
 {
-   return iris_screen_create(os_dupfd_cloexec(fd), config);
+   int newfd = os_dupfd_cloexec(fd);
+   if (newfd < 0)
+      return NULL;
+   return iris_screen_create(newfd, config);
 }