Skip to content

Commit 366fef7

Browse files
ij-intelIngo Molnar
authored andcommitted
<linux/cleanup.h>: Allow the passing of both iomem and non-iomem pointers to no_free_ptr()
Calling no_free_ptr() for an __iomem pointer results in Sparse complaining about the types: warning: incorrect type in argument 1 (different address spaces) expected void const volatile *val got void [noderef] __iomem *__val [ The example is from drivers/platform/x86/intel/pmc/core_ssram.c:283 ] The problem is caused by the signature of __must_check_fn() added in: 85be6d8 ("cleanup: Make no_free_ptr() __must_check") ... to enforce that the return value is always used. Use __force to allow both iomem and non-iomem pointers to be given for no_free_ptr(). Reported-by: kernel test robot <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Dan Williams <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/[email protected] Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
1 parent 80e54e8 commit 366fef7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/linux/cleanup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ const volatile void * __must_check_fn(const volatile void *val)
212212
{ return val; }
213213

214214
#define no_free_ptr(p) \
215-
((typeof(p)) __must_check_fn(__get_and_null(p, NULL)))
215+
((typeof(p)) __must_check_fn((__force const volatile void *)__get_and_null(p, NULL)))
216216

217217
#define return_ptr(p) return no_free_ptr(p)
218218

0 commit comments

Comments
 (0)