Skip to content

Commit f730fd5

Browse files
ubizjakPeter Zijlstra
authored andcommitted
cleanup: Remove address space of returned pointer
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: e4ab322 ("cleanup: Add conditional guard support") Signed-off-by: Uros Bizjak <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent d12b802 commit f730fd5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/linux/cleanup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static inline class_##_name##_t class_##_name##ext##_constructor(_init_args) \
290290
#define DEFINE_GUARD(_name, _type, _lock, _unlock) \
291291
DEFINE_CLASS(_name, _type, if (_T) { _unlock; }, ({ _lock; _T; }), _type _T); \
292292
static inline void * class_##_name##_lock_ptr(class_##_name##_t *_T) \
293-
{ return *_T; }
293+
{ return (void *)(__force unsigned long)*_T; }
294294

295295
#define DEFINE_GUARD_COND(_name, _ext, _condlock) \
296296
EXTEND_CLASS(_name, _ext, \
@@ -347,7 +347,7 @@ static inline void class_##_name##_destructor(class_##_name##_t *_T) \
347347
\
348348
static inline void *class_##_name##_lock_ptr(class_##_name##_t *_T) \
349349
{ \
350-
return _T->lock; \
350+
return (void *)(__force unsigned long)_T->lock; \
351351
}
352352

353353

0 commit comments

Comments
 (0)