Skip to content

Commit

Permalink
e1000e: fix numeric overflow in phc settime method
Browse files Browse the repository at this point in the history
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: Richard Cochran <richardcochran@gmail.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
  • Loading branch information
Richard Cochran authored and Jeff Kirsher committed Apr 26, 2013
1 parent 3a4e0d6 commit 73e3dd6
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/net/ethernet/intel/e1000e/ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ static int e1000e_phc_settime(struct ptp_clock_info *ptp,
unsigned long flags;
u64 ns;

ns = ts->tv_sec * NSEC_PER_SEC;
ns += ts->tv_nsec;
ns = timespec_to_ns(ts);

/* reset the timecounter */
spin_lock_irqsave(&adapter->systim_lock, flags);
Expand Down

0 comments on commit 73e3dd6

Please sign in to comment.