From: Benny Halevy <bhalevy@panasas.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: WARN_ON out of range error in ERR_PTR?
Date: Wed, 26 Nov 2008 17:48:08 +0200 [thread overview]
Message-ID: <492D6FB8.80401@panasas.com> (raw)
Andrew,
After hitting a bug where an nfs error -10021 wasn't handled
correctly since IS_ERR returned false on its ERR_PTR value
I realized that adding a BUG_ON to make sure the mapped error
is in the valid range would have caught this.
Since ERR_PTR is not called on the critical path
(unlike IS_ERR) but rather on the error handling path I believe
we can tolerate the extra cost.
The reason this is just a WARN_ON and not BUG_ON is to make
fixing it easier, although I do consider calling ERR_PTR on an
out of range error a pretty dangerous bug as the error might go
unnoticed.
How about committing the following patch to -mm?
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
---
include/linux/err.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/include/linux/err.h b/include/linux/err.h
index ec87f31..81df84f 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -2,7 +2,7 @@
#define _LINUX_ERR_H
#include <linux/compiler.h>
-
+#include <asm/bug.h>
#include <asm/errno.h>
/*
@@ -21,6 +21,7 @@
static inline void *ERR_PTR(long error)
{
+ WARN_ON(error && !IS_ERR_VALUE(error));
return (void *) error;
}
--
1.6.0.2
next reply other threads:[~2008-11-26 15:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-26 15:48 Benny Halevy [this message]
2008-11-27 0:15 ` WARN_ON out of range error in ERR_PTR? Andrew Morton
2008-11-27 6:27 ` Benny Halevy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=492D6FB8.80401@panasas.com \
--to=bhalevy@panasas.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox