mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [patch] err.h: IS_ERR() can accept __user pointers
       [not found] <CANeU7QnO8MzqT+9BDsXj3=nkKOBKumOwEKGnT=BL_cS0wiPPmw@mail.gmail.com>
@ 2013-05-08  7:42 ` Dan Carpenter
  2013-05-08  8:39   ` Christopher Li
  2013-05-08 22:16   ` Andrew Morton
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2013-05-08  7:42 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Christopher Li

Sparse generates a false positive when you pass a __user or __iomem
pointer to the IS_ERR() functions.

drivers/rtc/rtc-ds1286.c:344:36: sparse: incorrect type in argument 1 (different address spaces)
drivers/rtc/rtc-ds1286.c:344:36:    expected void const *ptr
drivers/rtc/rtc-ds1286.c:344:36:    got unsigned int [noderef] [usertype] <asn:2>*rtcregs

We can silence these by adding a __force here and upgrading to the
latest git release of Sparse.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
This change has no effect when using current Sparse releases.

diff --git a/include/linux/err.h b/include/linux/err.h
index f2edce2..221fcfb 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -24,17 +24,17 @@ static inline void * __must_check ERR_PTR(long error)
 	return (void *) error;
 }
 
-static inline long __must_check PTR_ERR(const void *ptr)
+static inline long __must_check PTR_ERR(__force const void *ptr)
 {
 	return (long) ptr;
 }
 
-static inline long __must_check IS_ERR(const void *ptr)
+static inline long __must_check IS_ERR(__force const void *ptr)
 {
 	return IS_ERR_VALUE((unsigned long)ptr);
 }
 
-static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
+static inline long __must_check IS_ERR_OR_NULL(__force const void *ptr)
 {
 	return !ptr || IS_ERR_VALUE((unsigned long)ptr);
 }
@@ -46,13 +46,13 @@ static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
  * Explicitly cast an error-valued pointer to another pointer type in such a
  * way as to make it clear that's what's going on.
  */
-static inline void * __must_check ERR_CAST(const void *ptr)
+static inline void * __must_check ERR_CAST(__force const void *ptr)
 {
 	/* cast away the const */
 	return (void *) ptr;
 }
 
-static inline int __must_check PTR_RET(const void *ptr)
+static inline int __must_check PTR_RET(__force const void *ptr)
 {
 	if (IS_ERR(ptr))
 		return PTR_ERR(ptr);

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] err.h: IS_ERR() can accept __user pointers
  2013-05-08  7:42 ` [patch] err.h: IS_ERR() can accept __user pointers Dan Carpenter
@ 2013-05-08  8:39   ` Christopher Li
  2013-05-08 22:16   ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Christopher Li @ 2013-05-08  8:39 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Andrew Morton, linux-kernel

On Wed, May 8, 2013 at 12:42 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Sparse generates a false positive when you pass a __user or __iomem
> pointer to the IS_ERR() functions.
>
> drivers/rtc/rtc-ds1286.c:344:36: sparse: incorrect type in argument 1 (different address spaces)
> drivers/rtc/rtc-ds1286.c:344:36:    expected void const *ptr
> drivers/rtc/rtc-ds1286.c:344:36:    got unsigned int [noderef] [usertype] <asn:2>*rtcregs
>
> We can silence these by adding a __force here and upgrading to the
> latest git release of Sparse.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> This change has no effect when using current Sparse releases.

Acked.

Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch] err.h: IS_ERR() can accept __user pointers
  2013-05-08  7:42 ` [patch] err.h: IS_ERR() can accept __user pointers Dan Carpenter
  2013-05-08  8:39   ` Christopher Li
@ 2013-05-08 22:16   ` Andrew Morton
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2013-05-08 22:16 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-kernel, Christopher Li

On Wed, 8 May 2013 10:42:22 +0300 Dan Carpenter <dan.carpenter@oracle.com> wrote:

> Sparse generates a false positive when you pass a __user or __iomem
> pointer to the IS_ERR() functions.
> 
> drivers/rtc/rtc-ds1286.c:344:36: sparse: incorrect type in argument 1 (different address spaces)
> drivers/rtc/rtc-ds1286.c:344:36:    expected void const *ptr
> drivers/rtc/rtc-ds1286.c:344:36:    got unsigned int [noderef] [usertype] <asn:2>*rtcregs
> 
> We can silence these by adding a __force here and upgrading to the
> latest git release of Sparse.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> This change has no effect when using current Sparse releases.

You often put really important stuff after the ^--- and I always move
it to before the ^--- :)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-08 22:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CANeU7QnO8MzqT+9BDsXj3=nkKOBKumOwEKGnT=BL_cS0wiPPmw@mail.gmail.com>
2013-05-08  7:42 ` [patch] err.h: IS_ERR() can accept __user pointers Dan Carpenter
2013-05-08  8:39   ` Christopher Li
2013-05-08 22:16   ` Andrew Morton

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®