From d17914ffc8ced48b97ac9be0b6e9da4f9b5fa914 Mon Sep 17 00:00:00 2001 From: Jessica Clarke Date: Wed, 16 Nov 2022 06:08:26 +0000 Subject: [PATCH] drm_os_freebsd: Fix drm_fstub_ioctl return value sign This function is at the FreeBSD/Linux boundary, with unlocked_ioctl conforming to Linux's return value conventions, i.e. errors are negative, and drm_fstub_ioctl conforming to FreeBSD's, i.e. errors are positive. Thus, negate the return value here to translate between the two, otherwise userspace will see negated errno values that don't match any known value; in particular, libdrm's drmIsMaster will erroneously always return true, which breaks KWin leasing a DRM fd to Xwayland. This also matches what linuxkpi does, as used by drm-kmod. --- freebsd/drm_os_freebsd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freebsd/drm_os_freebsd.c b/freebsd/drm_os_freebsd.c index 890a1ae..2d21b3e 100644 --- a/freebsd/drm_os_freebsd.c +++ b/freebsd/drm_os_freebsd.c @@ -267,7 +267,7 @@ drm_fstub_ioctl(struct file *file, u_long cmd, void *data, struct ucred *cred, goto out_release; } - rv = fops->unlocked_ioctl(file, cmd, (unsigned long)data); + rv = -fops->unlocked_ioctl(file, cmd, (unsigned long)data); dev_relthread(cdev, ref); return (rv);