diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-03 14:08:36 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-03 14:09:26 +0100 |
commit | 58b26055f428fd6a99ffb889caa5e2472352b641 (patch) | |
tree | ded307c894e30934190c8590b998d8d423015cc9 /src | |
parent | b7d5292e01fb43d93c13c60a3cef16d352307bdf (diff) |
intel: Querying device attributes must be non-NULL
Check first for a NULL platform device before querying the attributes or
else suffer a segfault during PCI probing.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel_device.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/intel_device.c b/src/intel_device.c index c41179a4..668ce19b 100644 --- a/src/intel_device.c +++ b/src/intel_device.c @@ -223,8 +223,16 @@ static char *find_render_node(int fd) #if defined(ODEV_ATTRIB_PATH) static char *get_path(struct xf86_platform_device *dev) { - const char *path = xf86_get_platform_device_attrib(dev, ODEV_ATTRIB_PATH); - return path ? strdup(path) : NULL; + const char *path; + + if (dev == NULL) + return NULL; + + path = xf86_get_platform_device_attrib(dev, ODEV_ATTRIB_PATH); + if (path == NULL) + return NULL; + + return strdup(path); } #else @@ -239,9 +247,15 @@ static char *get_path(struct xf86_platform_device *dev) #if defined(ODEV_ATTRIB_FD) && 0 static int get_fd(struct xf86_platform_device *dev) { - const char *str = xf86_get_platform_device_attrib(dev, ODEV_ATTRIB_FD); + const char *str; + + if (dev == NULL) + return -1; + + str = xf86_get_platform_device_attrib(dev, ODEV_ATTRIB_FD); if (str == NULL) return -1; + return atoi(str); } |