[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1363653565-16388-1-git-send-email-gheorghiuandru@gmail.com>
Date: Tue, 19 Mar 2013 02:39:25 +0200
From: Alexandru Gheorghiu <gheorghiuandru@...il.com>
To: Richard Cochran <richardcochran@...il.com>
Cc: linux-kernel@...r.kernel.org,
Alexandru Gheorghiu <gheorghiuandru@...il.com>
Subject: [PATCH] drivers: ptp: Use memdup_user function
Used memdup_user function instead of kmalloc followed by copy_from_user.
Also, handled return error using IS_ERR and PTR_ERR.
Patch found using coccinelle.
Signed-off-by: Alexandru Gheorghiu <gheorghiuandru@...il.com>
---
drivers/ptp/ptp_chardev.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index 34a0c60..bd7a2ab 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -94,14 +94,9 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
break;
case PTP_SYS_OFFSET:
- sysoff = kmalloc(sizeof(*sysoff), GFP_KERNEL);
- if (!sysoff) {
- err = -ENOMEM;
- break;
- }
- if (copy_from_user(sysoff, (void __user *)arg,
- sizeof(*sysoff))) {
- err = -EFAULT;
+ sysoff = memdup_user((void __user *)arg, sizeof(*sysoff));
+ if (IS_ERR(sysoff)) {
+ err = PTR_ERR(sysoff);
break;
}
if (sysoff->n_samples > PTP_MAX_SAMPLES) {
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists