diff mbox series

[U-Boot,2/3] linux err: make ERR_PTR/PTR_ERR architecture specific

Message ID 20191022192948.11080-3-simon.k.r.goldschmidt@gmail.com
State Accepted
Commit 8c59ca93b839261863f0db2295a2b6b4dd4f175e
Delegated to: Tom Rini
Headers show
Series make ERR_PTR/PTR_ERR architecture specific | expand

Commit Message

Simon Goldschmidt Oct. 22, 2019, 7:29 p.m. UTC
This patch changes ERR_PTR/PTR_ERR to use CONFIG_ERR_PTR_OFFSET to map
errno values into a pointer region that cannot contain valid pointers.

IS_ERR and IS_ERR_OR_NULL have to be converted to use PTR_ERR, too,
for this to work.

Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
---

 include/linux/err.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Tom Rini Nov. 8, 2019, 3:32 p.m. UTC | #1
On Tue, Oct 22, 2019 at 09:29:47PM +0200, Simon Goldschmidt wrote:

> This patch changes ERR_PTR/PTR_ERR to use CONFIG_ERR_PTR_OFFSET to map
> errno values into a pointer region that cannot contain valid pointers.
> 
> IS_ERR and IS_ERR_OR_NULL have to be converted to use PTR_ERR, too,
> for this to work.
> 
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/include/linux/err.h b/include/linux/err.h
index 22e5756edd..5ede82432d 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -23,22 +23,22 @@ 
 
 static inline void *ERR_PTR(long error)
 {
-	return (void *) error;
+	return (void *)(CONFIG_ERR_PTR_OFFSET + error);
 }
 
 static inline long PTR_ERR(const void *ptr)
 {
-	return (long) ptr;
+	return ((long)ptr - CONFIG_ERR_PTR_OFFSET);
 }
 
 static inline long IS_ERR(const void *ptr)
 {
-	return IS_ERR_VALUE((unsigned long)ptr);
+	return IS_ERR_VALUE((unsigned long)PTR_ERR(ptr));
 }
 
 static inline bool IS_ERR_OR_NULL(const void *ptr)
 {
-	return !ptr || IS_ERR_VALUE((unsigned long)ptr);
+	return !ptr || IS_ERR_VALUE((unsigned long)PTR_ERR(ptr));
 }
 
 /**