mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-01 18:53:30 +00:00
Merge branch 'posix-clock-fix-missing-timespec64-check-for-ptp-clock'
Jinjie Ruan says: ==================== posix-clock: Fix missing timespec64 check for PTP clock Check timespec64 in pc_clock_settime() for PTP clock as the man manual of clock_settime() said. ==================== Link: https://patch.msgid.link/20241009072302.1754567-1-ruanjinjie@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
e3e4e5667d
@ -401,28 +401,21 @@ static int lan743x_ptpci_settime64(struct ptp_clock_info *ptpci,
|
|||||||
u32 nano_seconds = 0;
|
u32 nano_seconds = 0;
|
||||||
u32 seconds = 0;
|
u32 seconds = 0;
|
||||||
|
|
||||||
if (ts) {
|
if (ts->tv_sec > 0xFFFFFFFFLL) {
|
||||||
if (ts->tv_sec > 0xFFFFFFFFLL ||
|
netif_warn(adapter, drv, adapter->netdev,
|
||||||
ts->tv_sec < 0) {
|
"ts->tv_sec out of range, %lld\n",
|
||||||
netif_warn(adapter, drv, adapter->netdev,
|
ts->tv_sec);
|
||||||
"ts->tv_sec out of range, %lld\n",
|
return -ERANGE;
|
||||||
ts->tv_sec);
|
|
||||||
return -ERANGE;
|
|
||||||
}
|
|
||||||
if (ts->tv_nsec >= 1000000000L ||
|
|
||||||
ts->tv_nsec < 0) {
|
|
||||||
netif_warn(adapter, drv, adapter->netdev,
|
|
||||||
"ts->tv_nsec out of range, %ld\n",
|
|
||||||
ts->tv_nsec);
|
|
||||||
return -ERANGE;
|
|
||||||
}
|
|
||||||
seconds = ts->tv_sec;
|
|
||||||
nano_seconds = ts->tv_nsec;
|
|
||||||
lan743x_ptp_clock_set(adapter, seconds, nano_seconds, 0);
|
|
||||||
} else {
|
|
||||||
netif_warn(adapter, drv, adapter->netdev, "ts == NULL\n");
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
if (ts->tv_nsec < 0) {
|
||||||
|
netif_warn(adapter, drv, adapter->netdev,
|
||||||
|
"ts->tv_nsec out of range, %ld\n",
|
||||||
|
ts->tv_nsec);
|
||||||
|
return -ERANGE;
|
||||||
|
}
|
||||||
|
seconds = ts->tv_sec;
|
||||||
|
nano_seconds = ts->tv_nsec;
|
||||||
|
lan743x_ptp_clock_set(adapter, seconds, nano_seconds, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -318,6 +318,9 @@ static int pc_clock_settime(clockid_t id, const struct timespec64 *ts)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!timespec64_valid_strict(ts))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
if (cd.clk->ops.clock_settime)
|
if (cd.clk->ops.clock_settime)
|
||||||
err = cd.clk->ops.clock_settime(cd.clk, ts);
|
err = cd.clk->ops.clock_settime(cd.clk, ts);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user