xf86drm: Fix segmentation fault while parsing device info
authorAndreas Baierl <ichgeh@imkreisrum.de>
Mon, 11 Mar 2019 15:04:08 +0000 (16:04 +0100)
committerEric Engestrom <eric.engestrom@intel.com>
Tue, 12 Mar 2019 11:55:31 +0000 (11:55 +0000)
This fixes a bug, which was introduced with commit ee798b98
"xf85drm: de-duplicate drmParse{Platform.Host1x}{Bus,Device}Info".
where accessing *compatible[i] with i>0 results in a segfault.

Signed-off-by: Andreas Baierl <ichgeh@imkreisrum.de>
Fixes: ee798b98479709acdd8d "xf85drm: de-duplicate drmParse{Platform.Host1x}{Bus,Device}Info"
Reviewed-by: Eric Engestrom <eric.engestrom@intel.com>
[Eric: add the same fix to the free() below]
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
xf86drm.c

index cbae3e2..18ad7c5 100644 (file)
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3629,14 +3629,14 @@ static int drmParseOFDeviceInfo(int maj, int min, char ***compatible)
             free(value);
         }
 
-        *compatible[i] = tmp_name;
+        (*compatible)[i] = tmp_name;
     }
 
     return 0;
 
 free:
     while (i--)
-        free(*compatible[i]);
+        free((*compatible)[i]);
 
     free(*compatible);
     return err;