linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Matt Porter <mporter@kernel.crashing.org>,
	Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] rapidio: mport_cdev: fix some error codes
Date: Fri, 12 Feb 2016 09:37:09 +0300	[thread overview]
Message-ID: <20160212063709.GA22756@mwanda> (raw)

copy_to_user() returns the number of bytes not copied but we want to
return an error code.

Fixes: a45bfc36bf0d ('rapidio: add mport char device driver')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 6d56725..a3369d1 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -2140,9 +2140,10 @@ static long mport_cdev_ioctl(struct file *filp,
 		return maint_port_idx_get(data, (void __user *)arg);
 	case RIO_MPORT_GET_PROPERTIES:
 		md->properties.hdid = md->mport->host_deviceid;
-		err = copy_to_user((void __user *)arg, &(data->md->properties),
-				   sizeof(data->md->properties));
-		break;
+		if (copy_to_user((void __user *)arg, &(data->md->properties),
+				 sizeof(data->md->properties)))
+			return -EFAULT;
+		return 0;
 	case RIO_ENABLE_DOORBELL_RANGE:
 		return rio_mport_add_db_filter(data, (void __user *)arg);
 	case RIO_DISABLE_DOORBELL_RANGE:
@@ -2155,8 +2156,10 @@ static long mport_cdev_ioctl(struct file *filp,
 		data->event_mask = arg;
 		return 0;
 	case RIO_GET_EVENT_MASK:
-		return copy_to_user((void __user *)arg, &data->event_mask,
-				    sizeof(data->event_mask));
+		if (copy_to_user((void __user *)arg, &data->event_mask,
+				    sizeof(data->event_mask)))
+			return -EFAULT;
+		return 0;
 	case RIO_MAP_OUTBOUND:
 		return rio_mport_obw_map(filp, (void __user *)arg);
 	case RIO_MAP_INBOUND:

             reply	other threads:[~2016-02-12  6:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-12  6:37 Dan Carpenter [this message]
2016-02-12 12:55 ` [patch] rapidio: mport_cdev: fix some error codes Bounine, Alexandre

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=20160212063709.GA22756@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexandre.bounine@idt.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mporter@kernel.crashing.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).