]> www.infradead.org Git - users/hch/misc.git/commitdiff
<linux/cleanup.h>: Allow the passing of both iomem and non-iomem pointers to no_free_...
authorIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Mon, 10 Mar 2025 12:21:58 +0000 (14:21 +0200)
committerIngo Molnar <mingo@kernel.org>
Mon, 10 Mar 2025 19:02:14 +0000 (20:02 +0100)
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:

  85be6d842447 ("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 <lkp@intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/20250310122158.20966-1-ilpo.jarvinen@linux.intel.com
Closes: https://lore.kernel.org/oe-kbuild-all/202403050547.qnZtuNlN-lkp@intel.com/
include/linux/cleanup.h

index ec00e3f7af2b3472f8c43c651402f3477fbb329c..ee2614adb78583af6a4fd2267ea177a8e099e05d 100644 (file)
@@ -212,7 +212,7 @@ const volatile void * __must_check_fn(const volatile void *val)
 { return val; }
 
 #define no_free_ptr(p) \
-       ((typeof(p)) __must_check_fn(__get_and_null(p, NULL)))
+       ((typeof(p)) __must_check_fn((__force const volatile void *)__get_and_null(p, NULL)))
 
 #define return_ptr(p)  return no_free_ptr(p)