]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ptp: oops in ptp_ioctl()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 26 May 2016 06:46:22 +0000 (09:46 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 30 May 2016 05:32:27 +0000 (22:32 -0700)
If we pass ERR_PTR(-EFAULT) to kfree() then it's going to oops.

Fixes: 772220f1a156 ('ptp: use memdup_user().')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/ptp/ptp_chardev.c

index 0b1ac6be69ce8d2a73d58432badb7bf7262ad5b6..d637c933c8a90655ffe152101dda2b9c71fd3836 100644 (file)
@@ -211,6 +211,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
                sysoff = memdup_user((void __user *)arg, sizeof(*sysoff));
                if (IS_ERR(sysoff)) {
                        err = PTR_ERR(sysoff);
+                       sysoff = NULL;
                        break;
                }
                if (sysoff->n_samples > PTP_MAX_SAMPLES) {