@@ -47,12 +47,12 @@
#include <rdma/ib_umem.h>
#include <rdma/ib_user_verbs.h>
-#define INIT_UDATA(udata, ibuf, obuf, ilen, olen) \
- do { \
- (udata)->inbuf = (const void __user *) (ibuf); \
- (udata)->outbuf = (void __user *) (obuf); \
- (udata)->inlen = (ilen); \
- (udata)->outlen = (olen); \
+#define INIT_UDATA(udata, ibuf, obuf, ilen, olen) \
+ do { \
+ (udata)->inbuf = (ibuf); \
+ (udata)->outbuf = (obuf); \
+ (udata)->inlen = (ilen); \
+ (udata)->outlen = (olen); \
} while (0)
/*
@@ -635,6 +635,7 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
__u32 command;
struct ib_uverbs_ex_cmd_hdr ex_hdr;
+ char __user *response;
struct ib_udata ucore;
struct ib_udata uhw;
int err;
@@ -668,7 +669,9 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
if ((hdr.in_words + ex_hdr.provider_in_words) * 8 != count)
return -EINVAL;
- if (ex_hdr.response) {
+ response = (char __user *)(unsigned long)ex_hdr.response;
+
+ if (response) {
if (!hdr.out_words && !ex_hdr.provider_out_words)
return -EINVAL;
} else {
@@ -677,14 +680,14 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
}
INIT_UDATA(&ucore,
- (hdr.in_words) ? buf : 0,
- (unsigned long)ex_hdr.response,
+ (hdr.in_words) ? buf : NULL,
+ response,
hdr.in_words * 8,
hdr.out_words * 8);
INIT_UDATA(&uhw,
- (ex_hdr.provider_in_words) ? buf + ucore.inlen : 0,
- (ex_hdr.provider_out_words) ? (unsigned long)ex_hdr.response + ucore.outlen : 0,
+ (ex_hdr.provider_in_words) ? buf + ucore.inlen : NULL,
+ (ex_hdr.provider_out_words) ? response + ucore.outlen : NULL,
ex_hdr.provider_in_words * 8,
ex_hdr.provider_out_words * 8);