Re: [PATCH i-g-t] lib/igt_kms: Fix build warning in igt_display_drop_events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Tvrtko Ursulin (2018-01-09 12:47:04)
> From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
> 
> Check read(2) return for robustness and to silence gcc.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>
> Cc: Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>

Hmm, mildly concerned about ev.length. A long time ago when I was last
in the event queue, we guaranteed writing whole requests and nothing but
whole requests.

> ---
>  lib/igt_kms.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index ec3b716791a2..c8f30d2c8a54 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -3155,10 +3155,11 @@ int igt_display_drop_events(igt_display_t *display)
>                 struct drm_event ev;
>                 char buf[128];
>  
> -               read(display->drm_fd, &ev, sizeof(ev));
> +               igt_assert_eq(read(display->drm_fd, &ev, sizeof(ev)),
> +                             sizeof(ev));
>                 igt_info("Dropping event type %u length %u\n", ev.type, ev.length);
>                 igt_assert(ev.length <= sizeof(buf));
> -               read(display->drm_fd, buf, ev.length);
> +               igt_assert_eq(read(display->drm_fd, buf, ev.length), ev.length);

What we do in drm_read() is

	copy_to_user(buffer, e->event, e->event->length)

so this read here is too long (as its sizeof(event) + event.length). The
assert will one day blow up... But only because the code is incorrect.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux