summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2016-03-30 10:59:36 -0500
committerChih-Wei Huang <cwhuang@linux.org.tw>2016-04-01 13:56:07 +0800
commitf61f81e90e264df6f5c72f07e81cff91fc79bdf7 (patch)
treec0d56980f492aa1db8b82a7d8fe3937268b7262c
parent24e22e3e024d0779e4d93546c51e31816b7a6186 (diff)
downloadexternal_drm_gralloc-f61f81e90e264df6f5c72f07e81cff91fc79bdf7.zip
external_drm_gralloc-f61f81e90e264df6f5c72f07e81cff91fc79bdf7.tar.gz
external_drm_gralloc-f61f81e90e264df6f5c72f07e81cff91fc79bdf7.tar.bz2
drm_gralloc: pipe: add error handling for NULL load_pipe_screen
Check load_pipe_screen for NULL and return in case dlsym returns a NULL pointer. This can happen if the correct gallium driver is not enabled. Signed-off-by: Rob Herring <robh@kernel.org>
-rw-r--r--gralloc_drm_pipe.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/gralloc_drm_pipe.c b/gralloc_drm_pipe.c
index e44293c..5cc7dc8 100644
--- a/gralloc_drm_pipe.c
+++ b/gralloc_drm_pipe.c
@@ -386,18 +386,16 @@ struct gralloc_drm_drv_t *gralloc_drm_drv_create_for_pipe(int fd, const char *na
pthread_mutex_init(&pm->mutex, NULL);
pm->gallium = dlopen(DRI_LIBRARY_PATH"/gallium_dri.so", RTLD_NOW | RTLD_GLOBAL);
- if (!pm->gallium) {
- FREE(pm);
- return NULL;
- }
+ if (!pm->gallium)
+ goto err_open;
+
load_pipe_screen = dlsym(pm->gallium, "load_pipe_screen");
+ if (!load_pipe_screen)
+ goto err_load;
pm->screen = load_pipe_screen(&pm->dev, fd);
- if (!pm->screen) {
- dlclose(pm->gallium);
- FREE(pm);
- return NULL;
- }
+ if (!pm->screen)
+ goto err_load;
pm->base.destroy = pipe_destroy;
pm->base.init_kms_features = pipe_init_kms_features;
@@ -408,4 +406,10 @@ struct gralloc_drm_drv_t *gralloc_drm_drv_create_for_pipe(int fd, const char *na
pm->base.blit = pipe_blit;
return &pm->base;
+
+err_load:
+ dlclose(pm->gallium);
+err_open:
+ FREE(pm);
+ return NULL;
}