summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2019-01-17 15:15:35 +0300
committerMatthew Wilcox <willy@infradead.org>2019-01-17 15:19:42 +0300
commitedcddd4c879af48ec922d680b2d56834c085683b (patch)
treeef09fbfa2d681e0e1edb9005453d42d87d205d04 /include/linux
parentd69d287a9002b70bdbe2975660b97241ccefc071 (diff)
downloadlinux-edcddd4c879af48ec922d680b2d56834c085683b.tar.xz
XArray: Fix an arithmetic error in xa_is_err
There is a math problem here which leads to a lot of static checker warnings for me: net/sunrpc/clnt.c:451 rpc_new_client() error: (-4096) too low for ERR_PTR Error values are from -1 to -4095 or from 0xffffffff to 0xfffff001 in hexadecimal. (I am assuming a 32 bit system for simplicity). We are using the lowest two bits to hold some internal XArray data so the error is shifted two spaces to the left. 0xfffff001 << 2 is 0xffffc004. And finally we want to check that BIT(1) is set so we add 2 which gives us 0xffffc006. In other words, we should be checking that "entry >= 0xffffc006", but the check is actually testing if "entry >= 0xffffc002". Fixes: 76b4e5299565 ("XArray: Permit storing 2-byte-aligned pointers") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> [Use xa_mk_internal() instead of changing the bracketing] Signed-off-by: Matthew Wilcox <willy@infradead.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/xarray.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/xarray.h b/include/linux/xarray.h
index 7da665f5cb20..5d9d318bcf7a 100644
--- a/include/linux/xarray.h
+++ b/include/linux/xarray.h
@@ -177,7 +177,7 @@ static inline bool xa_is_internal(const void *entry)
static inline bool xa_is_err(const void *entry)
{
return unlikely(xa_is_internal(entry) &&
- (unsigned long)entry >= -((MAX_ERRNO << 2) + 2));
+ entry >= xa_mk_internal(-MAX_ERRNO));
}
/**