* [PATCH v2 1/1] cleanup: Fix sparse complaining about passing iomem ptr to no_free_ptr()
@ 2025-03-10 12:21 Ilpo Järvinen
2025-03-10 19:09 ` [tip: core/urgent] <linux/cleanup.h>: Allow the passing of both iomem and non-iomem pointers " tip-bot2 for Ilpo Järvinen
0 siblings, 1 reply; 2+ messages in thread
From: Ilpo Järvinen @ 2025-03-10 12:21 UTC (permalink / raw)
To: Peter Zijlstra, platform-driver-x86, linux-kernel
Cc: Rajneesh Bhardwaj, David E Box, Hans de Goede, Christian Brauner,
Al Viro, Ingo Molnar, Przemek Kitszel, David Lechner,
Uros Bizjak, Linus Torvalds, Ilpo Järvinen,
kernel test robot, Andy Shevchenko, Dan Williams
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 from drivers/platform/x86/intel/pmc/core_ssram.c:283).
The problem is caused by the signature of __must_check_fn() added in
the commit 85be6d842447 ("cleanup: Make no_free_ptr() __must_check") to
enforce 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>
Closes: https://lore.kernel.org/oe-kbuild-all/202403050547.qnZtuNlN-lkp@intel.com/
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
I've no strong preferences through which tree this patch is routed.
v2:
- Rebased & updated line number to match the current code.
include/linux/cleanup.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/cleanup.h b/include/linux/cleanup.h
index ec00e3f7af2b..ee2614adb785 100644
--- a/include/linux/cleanup.h
+++ b/include/linux/cleanup.h
@@ -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)
base-commit: 80e54e84911a923c40d7bee33a34c1b4be148d7a
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* [tip: core/urgent] <linux/cleanup.h>: Allow the passing of both iomem and non-iomem pointers to no_free_ptr()
2025-03-10 12:21 [PATCH v2 1/1] cleanup: Fix sparse complaining about passing iomem ptr to no_free_ptr() Ilpo Järvinen
@ 2025-03-10 19:09 ` tip-bot2 for Ilpo Järvinen
0 siblings, 0 replies; 2+ messages in thread
From: tip-bot2 for Ilpo Järvinen @ 2025-03-10 19:09 UTC (permalink / raw)
To: linux-tip-commits
Cc: kernel test robot, ilpo.jarvinen, Ingo Molnar, Andy Shevchenko,
Dan Williams, H. Peter Anvin, Linus Torvalds, x86, linux-kernel
The following commit has been merged into the core/urgent branch of tip:
Commit-ID: 366fef794bd2b7c2e9df933f6828dd9739bfba84
Gitweb: https://git.kernel.org/tip/366fef794bd2b7c2e9df933f6828dd9739bfba84
Author: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
AuthorDate: Mon, 10 Mar 2025 14:21:58 +02:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 10 Mar 2025 20:02:14 +01:00
<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:
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 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/cleanup.h b/include/linux/cleanup.h
index ec00e3f..ee2614a 100644
--- a/include/linux/cleanup.h
+++ b/include/linux/cleanup.h
@@ -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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-10 19:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-10 12:21 [PATCH v2 1/1] cleanup: Fix sparse complaining about passing iomem ptr to no_free_ptr() Ilpo Järvinen
2025-03-10 19:09 ` [tip: core/urgent] <linux/cleanup.h>: Allow the passing of both iomem and non-iomem pointers " tip-bot2 for Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®