From: Okash Khawaja <okash.khawaja@gmail.com>
To: dan.carpenter@oracle.com, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org
Subject: [PATCH v2] staging: gdm72xx: fix address space warnings
Date: Fri, 11 Dec 2015 18:15:53 +0000 [thread overview]
Message-ID: <20151211181553.GA17969@bytefire-computer> (raw)
In-Reply-To: <20151202131724.GT18797@mwanda>
copy_to_user() and copy_from_user() functions expect the user space
pointers to be marked with __user. Sparse throws following warnings.
For copy_to_user():
warning: incorrect type in argument 1 (different address spaces)
expected void [noderef] <asn:1>*to
got void *buf
For copy_from_user():
warning: incorrect type in argument 2 (different address spaces)
expected void const [noderef] <asn:1>*from
got void *buf
This creates a separate `struct udata_s` which is user space counterpart
of `struct data_s`. This patch also alters function signatures where
data transfer between user and kernel space occurs, in order to make the
distinction explicit. Finally, it explicitly casts the argument passed
to `gdm_update_fsm()` using __force to avoid the warning "cast removes
address space of expression".
Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
---
drivers/staging/gdm72xx/gdm_wimax.c | 7 ++++---
drivers/staging/gdm72xx/wm_ioctl.h | 7 ++++++-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
index b8eea21..c61ce92 100644
--- a/drivers/staging/gdm72xx/gdm_wimax.c
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -363,7 +363,7 @@ static void kdelete(void **buf)
}
}
-static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)
+static int gdm_wimax_ioctl_get_data(struct udata_s *dst, struct data_s *src)
{
int size;
@@ -379,7 +379,7 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)
return 0;
}
-static int gdm_wimax_ioctl_set_data(struct data_s *dst, struct data_s *src)
+static int gdm_wimax_ioctl_set_data(struct data_s *dst, struct udata_s *src)
{
if (!src->size) {
dst->size = 0;
@@ -478,7 +478,8 @@ static int gdm_wimax_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
* before gdm_wimax_ioctl_set_data is called.
*/
gdm_update_fsm(dev,
- req->data.buf);
+ (__force struct fsm_s *)
+ req->data.buf);
}
ret = gdm_wimax_ioctl_set_data(
&nic->sdk_data[req->data_id], &req->data);
diff --git a/drivers/staging/gdm72xx/wm_ioctl.h b/drivers/staging/gdm72xx/wm_ioctl.h
index ed8f649..7dc8f6f 100644
--- a/drivers/staging/gdm72xx/wm_ioctl.h
+++ b/drivers/staging/gdm72xx/wm_ioctl.h
@@ -78,13 +78,18 @@ struct data_s {
void *buf;
};
+struct udata_s {
+ unsigned int size;
+ void __user *buf;
+};
+
struct wm_req_s {
union {
char ifrn_name[IFNAMSIZ];
} ifr_ifrn;
unsigned short cmd;
unsigned short data_id;
- struct data_s data;
+ struct udata_s data;
/* NOTE: sizeof(struct wm_req_s) must be less than sizeof(struct ifreq). */
};
--
2.5.2
next prev parent reply other threads:[~2015-12-11 18:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-29 20:40 [PATCH] staging: gdm72xx: fix address space parse warnings Okash Khawaja
2015-12-02 13:17 ` Dan Carpenter
2015-12-11 10:33 ` Okash Khawaja
2015-12-11 10:52 ` Dan Carpenter
2015-12-11 11:16 ` Okash Khawaja
2015-12-11 18:15 ` Okash Khawaja [this message]
2015-12-12 8:35 ` [PATCH v2] staging: gdm72xx: fix address space warnings Dan Carpenter
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=20151211181553.GA17969@bytefire-computer \
--to=okash.khawaja@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.