lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 19 May 2008 00:01:07 +0200
From:	Marcin Slusarz <marcin.slusarz@...il.com>
To:	LKML <linux-kernel@...r.kernel.org>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Al Viro <viro@...IV.linux.org.uk>,
	Christoph Hellwig <hch@....de>
Subject: [PATCH 2/6] ERR_PTR: add ERR_OR_0_PTR

Some codepaths call ERR_PTR with possibly 0 argument, which is not
a valid errno and rely on conversion from 0 to NULL pointer.
Add ERR_OR_0_PTR function which accepts errnos and 0 as an argument.

Signed-off-by: Marcin Slusarz <marcin.slusarz@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
---
 include/linux/err.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/include/linux/err.h b/include/linux/err.h
index 7b5daa6..cdec8b6 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -26,6 +26,13 @@ static inline void *__ERR_PTR(long error)
 
 #define ERR_PTR(error) (BUILD_BUG_ON(__builtin_constant_p(error) && !IS_ERR_VALUE(error)), __ERR_PTR(error))
 
+static inline void *__ERR_OR_0_PTR(long error)
+{
+	return (void *) error;
+}
+
+#define ERR_OR_0_PTR(error) (BUILD_BUG_ON(__builtin_constant_p(error) && error && !IS_ERR_VALUE(error)), __ERR_OR_0_PTR(error))
+
 static inline long PTR_ERR(const void *ptr)
 {
 	return (long) ptr;
-- 
1.5.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ