ptp: check gettime64 return code in PTP_SYS_OFFSET ioctl

If a gettime64 call fails, return the error and avoid copying data back
to user.

Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Miroslav Lichvar 2018-11-09 11:14:43 +01:00 committed by David S. Miller
parent fbb960ac26
commit 83d0bdc739
1 changed files with 4 additions and 1 deletions

View File

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