OSDN Git Service

gralloc_drm_kms: fix possible segfault
authorChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 3 Jan 2018 10:33:49 +0000 (18:33 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Thu, 4 Jan 2018 02:30:38 +0000 (10:30 +0800)
Check if the output is valid before using it.

gralloc_drm_kms.c

index dc3d633..667b500 100644 (file)
@@ -1123,6 +1123,10 @@ static int init_external_output(struct gralloc_drm_t *drm,
 {
        struct gralloc_drm_output *output;
        output = drm_kms_init_with_new_connector(drm, connector);
+       if (output == NULL || !output->active) {
+               ALOGW("connector 0x%x output is null or not active", connector->connector_id);
+               return -EINVAL;
+       }
 
        ALOGD("%s, allocate private buffer for hdmi [%dx%d]",
                __func__, output->mode.hdisplay, output->mode.vdisplay);