xf86-video-intel: src/intel_device.c
Chris Wilson
ickle at kemper.freedesktop.org
Thu Oct 3 06:09:41 PDT 2013
src/intel_device.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
New commits:
commit 58b26055f428fd6a99ffb889caa5e2472352b641
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Oct 3 14:08:36 2013 +0100
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 at chris-wilson.co.uk>
diff --git a/src/intel_device.c b/src/intel_device.c
index c41179a..668ce19 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);
}
More information about the xorg-commit
mailing list