[PATCH] drmPrime*: initialize output args to 0

Emil Velikov emil.l.velikov at gmail.com
Tue May 5 08:12:10 PDT 2015


Hi Guillaume,

On 29 April 2015 at 09:16, Guillaume Desmottes
<guillaume.desmottes at collabora.co.uk> wrote:
> Fix Valgrind errors because those memory was uninitialized.
>
> https://bugs.freedesktop.org/show_bug.cgi?id=90194
> Signed-off-by: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
> ---
>  xf86drm.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/xf86drm.c b/xf86drm.c
> index f7c45f8..01c398e 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -2724,6 +2724,7 @@ int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd)
>         struct drm_prime_handle args;
>         int ret;
>
> +       args.fd = -1;
>         args.handle = handle;
>         args.flags = flags;
>         ret = drmIoctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args);
> @@ -2739,6 +2740,7 @@ int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle)
>         struct drm_prime_handle args;
>         int ret;
>
> +       args.handle = 0;
>         args.fd = prime_fd;
>         args.flags = 0;
>         ret = drmIoctl(fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &args);

As mentioned before one could add the appropriate Valgrind
annotations. Although using memclear() or this will do just fine :-)
Any objections against memclear ? it will save us some head-scratching
when/if someone decides to extend struct drm_prime_handle. If you and
others are ok with it, I'll amend the patch locally before pushing in
the next week or so.

Thanks
Emil


More information about the dri-devel mailing list