drm: add __user attribute to ptr_to_compat()
Subsystems (2)
PATCH 1/1 drm: add __user attribute to ptr_to_compat()
The ptr_to_compat() call takes a "void __user *", so cast the compat drm calls that use it to avoid the following warnings from sparse:
drivers/gpu/drm/drm_ioc32.c:188:39: warning: incorrect type in argument 1 (different address spaces)drivers/gpu/drm/drm_ioc32.c:188:39: expected void [noderef] <asn:1>*uptrdrivers/gpu/drm/drm_ioc32.c:188:39: got void *[addressable] [assigned] handledrivers/gpu/drm/drm_ioc32.c:529:41: warning: incorrect type in argument 1 (different address spaces)drivers/gpu/drm/drm_ioc32.c:529:41: expected void [noderef] <asn:1>*uptrdrivers/gpu/drm/drm_ioc32.c:529:41: got void *[addressable] [assigned] handle
--- drivers/gpu/drm/drm_ioc32.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_ioc32.c +3 -3
@@ -185,7 +185,7 @@ static int compat_drm_getmap(struct file *file, unsigned int cmd, m32.size = map.size; m32.type = map.type; m32.flags = map.flags; - m32.handle =ptr_to_compat (map.handle); + m32.handle =ptr_to_compat ((void __user *)map.handle); m32.mtrr = map.mtrr;if (copy_to_user (argp, &m32,sizeof (m32)))return -EFAULT ;
@@ -216,7 +216,7 @@ static int compat_drm_addmap(struct file *file, unsigned int cmd, m32.offset = map.offset; m32.mtrr = map.mtrr; - m32.handle =ptr_to_compat (map.handle); + m32.handle =ptr_to_compat ((void __user *)map.handle);if (map.handle !=compat_ptr (m32.handle))pr_err_ratelimited ("compat_drm_addmap truncated handle %p for type %d offset %x\n" , map.handle, m32.type, m32.offset);
@@ -526,7 +526,7 @@ static int compat_drm_getsareactx(struct file *file, unsigned int cmd,if (err)return err; - req32.handle =ptr_to_compat (req.handle); + req32.handle =ptr_to_compat ((void __user *)req.handle);if (copy_to_user (argp, &req32,sizeof (req32)))return -EFAULT ;
Signature · 6 lines
2.20.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 4 lines · Ben Dooks
The
ptr_to_compat()call takes a "void__user*", so cast the compat drm calls that use it to avoid the following warnings from sparse:
Quoted 8 lines
drivers/gpu/drm/drm_ioc32.c:188:39: warning: incorrect type in argument 1 (different address spaces)drivers/gpu/drm/drm_ioc32.c:188:39: expected void [noderef] <asn:1>*uptrdrivers/gpu/drm/drm_ioc32.c:188:39: got void *[addressable] [assigned] handledrivers/gpu/drm/drm_ioc32.c:529:41: warning: incorrect type in argument 1 (different address spaces)drivers/gpu/drm/drm_ioc32.c:529:41: expected void [noderef] <asn:1>*uptrdrivers/gpu/drm/drm_ioc32.c:529:41: got void *[addressable] [assigned] handleSigned-off-by Ben Dooks <[email protected]>
Thanks for your patch, I've applied it to drm-misc-next-fixes with cc: stable.
Sean
Quoted 38 lines
--- drivers/gpu/drm/drm_ioc32.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_ioc32.c +3
-3@@ -185,7 +185,7 @@ static int compat_drm_getmap(struct file *file, unsigned int cmd, m32.size = map.size; m32.type = map.type; m32.flags = map.flags; - m32.handle =ptr_to_compat (map.handle); + m32.handle =ptr_to_compat ((void __user *)map.handle); m32.mtrr = map.mtrr;if (copy_to_user (argp, &m32,sizeof (m32)))return -EFAULT ;@@ -216,7 +216,7 @@ static int compat_drm_addmap(struct file *file, unsigned int cmd, m32.offset = map.offset; m32.mtrr = map.mtrr; - m32.handle =ptr_to_compat (map.handle); + m32.handle =ptr_to_compat ((void __user *)map.handle);if (map.handle !=compat_ptr (m32.handle))pr_err_ratelimited ("compat_drm_addmap truncated handle %p for type %d offset %x\n" , map.handle, m32.type, m32.offset);@@ -526,7 +526,7 @@ static int compat_drm_getsareactx(struct file *file, unsigned int cmd,if (err)return err; - req32.handle =ptr_to_compat (req.handle); + req32.handle =ptr_to_compat ((void __user *)req.handle);if (copy_to_user (argp, &req32,sizeof (req32)))return -EFAULT ;Signature · 1 line
2.20.1
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel