[PATCH libdrm] freedreno: zero is a valid fd number, treat it as such

Emil Velikov emil.l.velikov at gmail.com
Tue Jul 14 06:50:04 PDT 2015


On 14 July 2015 at 09:14, Thierry Reding <thierry.reding at gmail.com> wrote:
> On Mon, Jul 13, 2015 at 02:52:09PM +0100, Emil Velikov wrote:
>> Abeit quite unlikely to get hit by this bug here, let just fix it.
>>
>> v2: Correct conditional (do not call ioctl(DRM_IOCTL_PRIME_HANDLE_TO_FD)
>> when we already have the fd).
>>
>> Cc: freedreno at lists.freedesktop.org
>> Cc: Rob Clark <robdclark at gmail.com>
>> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
>> ---
>>  freedreno/freedreno_bo.c | 6 +++---
>>  freedreno/kgsl/kgsl_bo.c | 1 +
>>  freedreno/msm/msm_bo.c   | 1 +
>>  3 files changed, 5 insertions(+), 3 deletions(-)
>
> I think there's another one in kgsl_pipe_destroy(). With that fixed,
> this is:
>
I was aiming at msm and anything kgsl related was an added bonus. But
sure will fix that.

> Reviewed-by: Thierry Reding <treding at nvidia.com>
>
> There are also a couple more like this in omap_drm.c (I suspect Rob
> copied from that =) that we may want to fix at the same time (in the
> same patch or a separate one).
>
Ack will do.

> There's also a few places where an fd is compared to -1 directly, which
> should be okay, but might be worth making consistent. I can send a patch
> if you're not pedantic enough. =)
>
Sure I'll do that. Personally I don't might if we go the opposite way
- always check against -1, as long as it's not fd == 0 :-)
Upon closer look something buggy showed up in drmOpenOnceWithType

    if (fd <= 0 || nr_fds == DRM_MAX_FDS)
       return fd;

Surely that cannot be right ?

Thanks
Emil


More information about the dri-devel mailing list