nouveau: zero structs passed to ioctl
RFC PATCH 1/1 nouveau: zero structs passed to ioctl
From: Marcin Slusarz <[email protected]>
Subject: [libdrm PATCH] nouveau: zero structs passed to ioctl
--- nouveau/nouveau_bo.c | 4 ++++ nouveau/nouveau_device.c | 1 + nouveau/nouveau_pushbuf.c | 2 ++ 3 files changed, 7 insertions(+), 0 deletions(-)
nouveau/nouveau_bo.c +4 -0
@@ -103,6 +103,7 @@ nouveau_bo_kfree(struct nouveau_bo_priv *nvbo) nvbo->map =NULL ; } +memset (&req,0 ,sizeof (req)); req.handle = nvbo->handle; nvbo->handle =0 ;drmIoctl (nvdev->fd,DRM_IOCTL_GEM_CLOSE , &req);
@@ -119,6 +120,7 @@ nouveau_bo_kalloc(struct nouveau_bo_priv *nvbo, struct nouveau_channel *chan)if (nvbo->handle)return 0 ; +memset (&req,0 ,sizeof (req)); req.channel_hint = chan ? chan->id :0 ; req.align = nvbo->align;
@@ -262,6 +264,7 @@ nouveau_bo_wrap(struct nouveau_device *dev, uint32_t handle,return ret; nvbo =nouveau_bo (*bo); +memset (&req,0 ,sizeof (req)); req.handle = handle; ret =drmCommandWriteRead (nvdev->fd,DRM_NOUVEAU_GEM_INFO , &req,sizeof (req));
@@ -315,6 +318,7 @@ nouveau_bo_handle_ref(struct nouveau_device *dev, uint32_t handle,struct drm_gem_open req;int ret; +memset (&req,0 ,sizeof (req)); req.name = handle; ret =drmIoctl (nvdev->fd,DRM_IOCTL_GEM_OPEN , &req);if (ret) {
nouveau/nouveau_device.c +1 -0
@@ -161,6 +161,7 @@ nouveau_device_get_param(struct nouveau_device *dev,if (!nvdev || !value)return -EINVAL ; +memset (&g,0 ,sizeof (g)); g.param = param; ret =drmCommandWriteRead (nvdev->fd,DRM_NOUVEAU_GETPARAM , &g,sizeof (g));
nouveau/nouveau_pushbuf.c +2 -0
@@ -112,6 +112,7 @@ nouveau_pushbuf_init_call(struct nouveau_channel *chan)struct nouveau_device *dev = chan->device;int i, ret; +memset (&req,0 ,sizeof (req)); req.channel = chan->id; req.handle =0 ; ret = drmCommandWriteRead(nouveau_device(dev)->fd,
@@ -201,6 +202,7 @@ nouveau_pushbuf_flush(struct nouveau_channel *chan, unsigned min) nvpb->base.remaining -=2 ; restart_cal: +memset (&req,0 ,sizeof (req)); req.channel = chan->id; req.handle = nvpb->buffer[nvpb->current]->handle; req.offset = nvpb->current_offset *4 ;
Signature · 1 line
1.6.6.rc3
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 1 line · Marcin Slusarz
Subject: [libdrm PATCH] nouveau: zero structs passed to ioctl
Why?
Any specific bug?
Quoted 7 lines
nouveau/nouveau_bo.c +1
-0+ memset(&req, 0, sizeof(req));req.handle =
nvbo->handle;nvbo->handle= 0;
drmIoctl(nvdev->fd,DRM_IOCTL_GEM_CLOSE, &req);
A message that is not in the archive (sent off-list or not yet received): b6fcc0a1001120721w2842ea6fq393a1abd880cfd85-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 5 lines · Alexey Dobriyan
Quoted 1 line · Marcin Slusarz
Subject: [libdrm PATCH] nouveau: zero structs passed to ioctl
Why?
To make it more reliable/predictable when someone will add a new field or start to use now unused field on the kernel side.
Quoted 1 line
Any specific bug?
No, all of these structs have unused or uninitialized fields which valgrind complained about.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 2 lines
No, all of these structs have unused or uninitialized fields which valgrind complained about.
I ment unused or outgoing fields.