Commit 73e3dd6b authored by Richard Cochran's avatar Richard Cochran Committed by Jeff Kirsher

e1000e: fix numeric overflow in phc settime method

The PTP Hardware Clock settime function in the e1000e driver
computes nanoseconds from a struct timespec. The code converts the
seconds field .tv_sec by multiplying it with NSEC_PER_SEC. However,
both operands are of type long, resulting in an unintended overflow.
The patch fixes the issue by using the helper function from time.h.

CC: stable <stable@vger.kernel.org>
Signed-off-by: default avatarRichard Cochran <richardcochran@gmail.com>
Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 3a4e0d6a
...@@ -145,8 +145,7 @@ static int e1000e_phc_settime(struct ptp_clock_info *ptp, ...@@ -145,8 +145,7 @@ static int e1000e_phc_settime(struct ptp_clock_info *ptp,
unsigned long flags; unsigned long flags;
u64 ns; u64 ns;
ns = ts->tv_sec * NSEC_PER_SEC; ns = timespec_to_ns(ts);
ns += ts->tv_nsec;
/* reset the timecounter */ /* reset the timecounter */
spin_lock_irqsave(&adapter->systim_lock, flags); spin_lock_irqsave(&adapter->systim_lock, flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment