]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
cleanup: Remove address space of returned pointer
authorUros Bizjak <ubizjak@gmail.com>
Mon, 19 Aug 2024 07:41:15 +0000 (09:41 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Dec 2024 12:52:54 +0000 (13:52 +0100)
[ Upstream commit f730fd535fc51573f982fad629f2fc6b4a0cde2f ]

Guard functions in local_lock.h are defined using DEFINE_GUARD() and
DEFINE_LOCK_GUARD_1() macros having lock type defined as pointer in
the percpu address space. The functions, defined by these macros
return value in generic address space, causing:

cleanup.h:157:18: error: return from pointer to non-enclosed address space

and

cleanup.h:214:18: error: return from pointer to non-enclosed address space

when strict percpu checks are enabled.

Add explicit casts to remove address space of the returned pointer.

Found by GCC's named address space checks.

Fixes: e4ab322fbaaa ("cleanup: Add conditional guard support")
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20240819074124.143565-1-ubizjak@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/cleanup.h

index d9e613803df15a2fea487967cdd497bbaf41e9bd..b3200ccb96186ac1ef826583ec340e813c4fec86 100644 (file)
@@ -154,7 +154,7 @@ static inline class_##_name##_t class_##_name##ext##_constructor(_init_args) \
 #define DEFINE_GUARD(_name, _type, _lock, _unlock) \
        DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \
        static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \
-       { return *_T; }
+       { return (void *)(__force unsigned long)*_T; }
 
 #define DEFINE_GUARD_COND(_name, _ext, _condlock) \
        EXTEND_CLASS(_name, _ext, \
@@ -211,7 +211,7 @@ static inline void class_##_name##_destructor(class_##_name##_t *_T)        \
                                                                        \
 static inline void *class_##_name##_lock_ptr(class_##_name##_t *_T)    \
 {                                                                      \
-       return _T->lock;                                                \
+       return (void *)(__force unsigned long)_T->lock;                 \
 }