Check at runtime whether error argument of ERR_PTR and ERR_OR_0_PTR
is valid. It can catch bugs which possibly lead to oops or panic earlier.
Currently there are > 600 calls of ERR_PTR with non-constant argument
in Linux kernel sources.
Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
---
include/linux/err.h | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/include/linux/err.h b/include/linux/err.h
index cdec8b6..51e2459 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -3,6 +3,7 @@
#include <linux/compiler.h>
+#include <asm/bug.h>
#include <asm/errno.h>
/*
@@ -21,6 +22,7 @@
static inline void *__ERR_PTR(long error)
{
+ WARN_ON(!IS_ERR_VALUE(error));
return (void *) error;
}
@@ -28,6 +30,7 @@ static inline void *__ERR_PTR(long error)
static inline void *__ERR_OR_0_PTR(long error)
{
+ WARN_ON(!IS_ERR_VALUE(error) && error);
return (void *) error;
}
--
1.5.4.5
--
| Greg Kroah-Hartman | [PATCH 004/196] Chinese: add translation of SubmittingPatches |
| Alan Stern | Re: 2.6.22-rc2-mm1 |
| Satyam Sharma | Re: [PATCH 0/24] make atomic_read() behave consistently across all architectures |
| William Lee Irwin III | Re: [Announce] [patch] Modular Scheduler Core and Completely Fair Scheduler [CFS] |
git: | |
| Dale Farnsworth | Re: [PATCH 03/39] mv643xx_eth: shorten reg names |
| Jarek Poplawski | Re: HTB accuracy for high speed |
| Gerrit Renker | [PATCH 15/37] dccp: Set per-connection CCIDs via socket options |
| Jarek Poplawski | [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
