ptp: oops in ptp_ioctl()
authorDan Carpenter <[email protected]>
Thu, 26 May 2016 06:46:22 +0000 (09:46 +0300)
committerDavid S. Miller <[email protected]>
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: 2ece068e1b1d ('ptp: use memdup_user().')
Signed-off-by: Dan Carpenter <[email protected]>
Acked-by: Richard Cochran <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
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) {