diff mbox

ptp: oops in ptp_ioctl()

Message ID 20160526064622.GA6776@mwanda
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Dan Carpenter May 26, 2016, 6:46 a.m. UTC
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 <dan.carpenter@oracle.com>

Comments

Richard Cochran May 26, 2016, 5:42 p.m. UTC | #1
On Thu, May 26, 2016 at 09:46:22AM +0300, Dan Carpenter wrote:
> If we pass ERR_PTR(-EFAULT) to kfree() then it's going to oops.

Thanks for catching this.

Acked-by: Richard Cochran <richardcochran@gmail.com>
David Miller May 30, 2016, 5:32 a.m. UTC | #2
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Thu, 26 May 2016 09:46:22 +0300

> 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 <dan.carpenter@oracle.com>

Applied, thanks.
diff mbox

Patch

diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c
index 0b1ac6b..d637c93 100644
--- a/drivers/ptp/ptp_chardev.c
+++ b/drivers/ptp/ptp_chardev.c
@@ -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) {