ptp: check gettime64 return code in PTP_SYS_OFFSET ioctl
authorMiroslav Lichvar <[email protected]>
Fri, 9 Nov 2018 10:14:43 +0000 (11:14 +0100)
committerDavid S. Miller <[email protected]>
Sat, 10 Nov 2018 03:43:50 +0000 (19:43 -0800)
If a gettime64 call fails, return the error and avoid copying data back
to user.

Cc: Richard Cochran <[email protected]>
Cc: Jacob Keller <[email protected]>
Signed-off-by: Miroslav Lichvar <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/ptp/ptp_chardev.c

index b54b8158ff8a9e5e42c7016be33fffe8e173620b..3c681bed570358de0dfdc3d71968da125339179b 100644 (file)
@@ -228,7 +228,9 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
                        pct->sec = ts.tv_sec;
                        pct->nsec = ts.tv_nsec;
                        pct++;
-                       ptp->info->gettime64(ptp->info, &ts);
+                       err = ptp->info->gettime64(ptp->info, &ts);
+                       if (err)
+                               goto out;
                        pct->sec = ts.tv_sec;
                        pct->nsec = ts.tv_nsec;
                        pct++;
@@ -281,6 +283,7 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg)
                break;
        }
 
+out:
        kfree(sysoff);
        return err;
 }