diff mbox

[libdrm] xd86drm: read more than 128 bytes of uevent in drmParsePciBusInfo

Message ID 20161111190411.19239-1-emil.l.velikov@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Emil Velikov Nov. 11, 2016, 7:04 p.m. UTC
From: Emil Velikov <emil.velikov@collabora.com>

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 <jeffbai@aosc.xyz>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98629
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
---
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(-)

Comments

Eric Engestrom Nov. 14, 2016, 11:11 a.m. UTC | #1
On Friday, 2016-11-11 19:04:11 +0000, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov@collabora.com>
> 
> 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 <jeffbai@aosc.xyz>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98629
> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
> ---
> 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(-)
> 
> diff --git a/xf86drm.c b/xf86drm.c
> index 676effc..80e2f27 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -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';

How about `sizeof(data)-1`?

Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>

>      close(fd);
>      if (ret < 0)
>          return -errno;
> -- 
> 2.10.2
>
diff mbox

Patch

diff --git a/xf86drm.c b/xf86drm.c
index 676effc..80e2f27 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -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;