linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Okash Khawaja <okash.khawaja@gmail.com>
To: gregkh@linuxfoundation.org, jonathankim@gctsemi.com, deanahn@gctsemi.com
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH] staging: gdm72xx: fix address space parse warnings
Date: Sun, 29 Nov 2015 20:40:45 +0000	[thread overview]
Message-ID: <20151129204044.GA8079@bytefire-computer> (raw)

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 patch casts the user space pointers to have __user by using __force.

Signed-off-by: Okash Khawaja <okash.khawaja@gmail.com>
---
 drivers/staging/gdm72xx/gdm_wimax.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
index d9ddced..16f8f35 100644
--- a/drivers/staging/gdm72xx/gdm_wimax.c
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -371,6 +371,7 @@ static void kdelete(void **buf)
 static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)
 {
 	int size;
+	void __user *p;
 
 	size = dst->size < src->size ? dst->size : src->size;
 
@@ -378,7 +379,9 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)
 	if (src->size) {
 		if (!dst->buf)
 			return -EINVAL;
-		if (copy_to_user(dst->buf, src->buf, size))
+
+		p = (__force void __user *)dst->buf;
+		if (copy_to_user(p, src->buf, size))
 			return -EFAULT;
 	}
 	return 0;
@@ -386,6 +389,8 @@ static int gdm_wimax_ioctl_get_data(struct data_s *dst, struct data_s *src)
 
 static int gdm_wimax_ioctl_set_data(struct data_s *dst, struct data_s *src)
 {
+	void __user *p;
+
 	if (!src->size) {
 		dst->size = 0;
 		return 0;
@@ -401,7 +406,8 @@ static int gdm_wimax_ioctl_set_data(struct data_s *dst, struct data_s *src)
 			return -ENOMEM;
 	}
 
-	if (copy_from_user(dst->buf, src->buf, src->size)) {
+	p = (__force void __user *)src->buf;
+	if (copy_from_user(dst->buf, p, src->size)) {
 		kdelete(&dst->buf);
 		return -EFAULT;
 	}
-- 
2.5.2


             reply	other threads:[~2015-11-29 20:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-29 20:40 Okash Khawaja [this message]
2015-12-02 13:17 ` [PATCH] staging: gdm72xx: fix address space parse warnings 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   ` [PATCH v2] staging: gdm72xx: fix address space warnings Okash Khawaja
2015-12-12  8:35     ` 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=20151129204044.GA8079@bytefire-computer \
    --to=okash.khawaja@gmail.com \
    --cc=deanahn@gctsemi.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jonathankim@gctsemi.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).