Skip to contentSkip to conversation

xd86drm: read more than 128 bytes of uevent in drmParsePciBusInfo

PATCH In review Emil Velikov 2 participants 2 messages Nov 11, 2016 – Nov 14, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xd86drm: read more than 128 bytes of uevent in drmParsePciBusInfo

From: Emil Velikov <[email protected]>

Some platforms (such as Macs using OF) can have more information in the uevent file thus reading only the first 128 might not be sufficient.

Bump it to 512, which "should be enough for everybody" ;-)

Cc: Mingcong Bai <[email protected]>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98629

---
Mingcong Bai, this should fix things but you'll need to apply it on top of your libdrm package. There's no need to rebuild mesa afterwords.

Note to self:
Strictly speaking we can rework drmGetDevice[s] to use [just] uevent...

---
 xf86drm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xf86drm.c +2 -2
index 676effc..80e2f27 100644
@@ -2871,7 +2871,7 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
 {
 #ifdef __linux__
     char path[PATH_MAX + 1];
-    char data[128 + 1];
+    char data[512 + 1];
     char *str;
     int domain, bus, dev, func;
     int fd, ret;
@@ -2882,7 +2882,7 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
         return -errno;
 
     ret = read(fd, data, sizeof(data));
-    data[128] = '\0';
+    data[512] = '\0';
     close(fd);
     if (ret < 0)
         return -errno;
Signature · 6 lines
2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 35 lines · Emil Velikov

From: Emil Velikov <[email protected]>

Some platforms (such as Macs using OF) can have more information in the uevent file thus reading only the first 128 might not be sufficient.

Bump it to 512, which "should be enough for everybody" ;-)

Cc: Mingcong Bai <[email protected]>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98629

---
Mingcong Bai, this should fix things but you'll need to apply it on top of your libdrm package. There's no need to rebuild mesa afterwords.

Note to self:
Strictly speaking we can rework drmGetDevice[s] to use [just] uevent...

---
 xf86drm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
xf86drm.c +1 -1
index 676effc..80e2f27 100644
@@ -2871,7 +2871,7 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
 {
 #ifdef __linux__
     char path[PATH_MAX + 1];
-    char data[128 + 1];
+    char data[512 + 1];
     char *str;
     int domain, bus, dev, func;
     int fd, ret;

xf86drm.c static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info) · line 2885

Quoted 5 lines
xf86drm.c +1 -1
@@ -2882,7 +2882,7 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
         return -errno;
 
     ret = read(fd, data, sizeof(data));
-    data[128] = '\0';
+    data[512] = '\0';

How about sizeof(data)-1?

Quoted 6 lines
xf86drm.c +0 -0
     close(fd);
     if (ret < 0)
         return -errno;
Signature · 1 line
2.10.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel