]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commit
uaccess: Fix scoped_user_read_access() for 'pointer to const'
authorDavid Laight <david.laight.linux@gmail.com>
Mon, 2 Mar 2026 13:27:51 +0000 (13:27 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 2 Mar 2026 17:24:32 +0000 (09:24 -0800)
commitaf4e9ef3d78420feb8fe58cd9a1ab80c501b3c08
tree58cb92516eaa9bdf7c1550654ce051ff5bc59c58
parent1b37ac211a22d4c65aad1ae2da07f078197e7394
uaccess: Fix scoped_user_read_access() for 'pointer to const'

If a 'const struct foo __user *ptr' is used for the address passed to
scoped_user_read_access() then you get a warning/error

  uaccess.h:691:1: error: initialization discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]

for the

  void __user *_tmpptr = __scoped_user_access_begin(mode, uptr, size, elbl)

assignment.

Fix by using 'auto' for both _tmpptr and the redeclaration of uptr.
Replace the CLASS() with explicit __cleanup() functions on uptr.

Fixes: e497310b4ffb ("uaccess: Provide scoped user access regions")
Signed-off-by: David Laight <david.laight.linux@gmail.com>
Reviewed-and-tested-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/uaccess.h