Source-Changes-HG archive

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

[src/trunk]: src/sys/external/bsd/drm2/dist/drm copy the output from the temp...



details:   https://anonhg.NetBSD.org/src/rev/6dd56e6bcbb0
branches:  trunk
changeset: 433418:6dd56e6bcbb0
user:      maya <maya%NetBSD.org@localhost>
date:      Fri Sep 14 05:31:14 2018 +0000

description:
copy the output from the temp buffer to the actual one on return.

Fixes crashes with updated xf86-video-intel / mesa 18
from riastradh.

diffstat:

 sys/external/bsd/drm2/dist/drm/drm_ioctl.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (54 lines):

diff -r 2b31674f8295 -r 6dd56e6bcbb0 sys/external/bsd/drm2/dist/drm/drm_ioctl.c
--- a/sys/external/bsd/drm2/dist/drm/drm_ioctl.c        Fri Sep 14 05:09:51 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/drm_ioctl.c        Fri Sep 14 05:31:14 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: drm_ioctl.c,v 1.10 2018/08/28 03:41:38 riastradh Exp $ */
+/*     $NetBSD: drm_ioctl.c,v 1.11 2018/09/14 05:31:14 maya Exp $      */
 
 /*
  * Created: Fri Jan  8 09:01:26 1999 by faith%valinux.com@localhost
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: drm_ioctl.c,v 1.10 2018/08/28 03:41:38 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: drm_ioctl.c,v 1.11 2018/09/14 05:31:14 maya Exp $");
 
 #include <drm/drmP.h>
 #include <drm/drm_core.h>
@@ -703,6 +703,7 @@
 {
        char stackbuf[128];
        char *buf = stackbuf;
+       void *data0 = data;
        struct drm_file *const file = fp->f_data;
        const unsigned int nr = DRM_IOCTL_NR(cmd);
        int error;
@@ -761,20 +762,24 @@
                memcpy(buf, data, IOCPARM_LEN(cmd));
                memset(buf + IOCPARM_LEN(cmd), 0,
                    IOCPARM_LEN(ioctl->cmd) - IOCPARM_LEN(cmd));
-               data = buf;
+               data0 = buf;
        }
 
        if ((drm_core_check_feature(dev, DRIVER_MODESET) && is_driver_ioctl) ||
            ISSET(ioctl->flags, DRM_UNLOCKED)) {
                /* XXX errno Linux->NetBSD */
-               error = -(*ioctl->func)(dev, data, file);
+               error = -(*ioctl->func)(dev, data0, file);
        } else {
                mutex_lock(&drm_global_mutex);
                /* XXX errno Linux->NetBSD */
-               error = -(*ioctl->func)(dev, data, file);
+               error = -(*ioctl->func)(dev, data0, file);
                mutex_unlock(&drm_global_mutex);
        }
 
+       /* If we used a temporary buffer, copy it back out.  */
+       if (data != data0)
+               memcpy(data, data0, IOCPARM_LEN(cmd));
+
        /* If we had to allocate a heap buffer, free it.  */
        if (buf != stackbuf)
                kmem_free(buf, IOCPARM_LEN(ioctl->cmd));



Home | Main Index | Thread Index | Old Index