Skip to content

Commit

Permalink
ice: check the return of ice_ptp_gettimex64
Browse files Browse the repository at this point in the history
commit ed22d9c upstream.

Clang static analysis reports this issue
time64.h:69:50: warning: The left operand of '+'
  is a garbage value
  set_normalized_timespec64(&ts_delta, lhs.tv_sec + rhs.tv_sec,
                                       ~~~~~~~~~~ ^
In ice_ptp_adjtime_nonatomic(), the timespec64 variable 'now'
is set by ice_ptp_gettimex64().  This function can fail
with -EBUSY, so 'now' can have a gargbage value.
So check the return.

Fixes: 06c16d8 ("ice: register 1588 PTP clock device object for E810 devices")
Signed-off-by: Tom Rix <trix@redhat.com>
Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Tom Rix authored and gregkh committed Mar 2, 2022
1 parent 7e8da99 commit b3615ea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/ethernet/intel/ice/ice_ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,9 +846,12 @@ ice_ptp_settime64(struct ptp_clock_info *info, const struct timespec64 *ts)
static int ice_ptp_adjtime_nonatomic(struct ptp_clock_info *info, s64 delta)
{
struct timespec64 now, then;
int ret;

then = ns_to_timespec64(delta);
ice_ptp_gettimex64(info, &now, NULL);
ret = ice_ptp_gettimex64(info, &now, NULL);
if (ret)
return ret;
now = timespec64_add(now, then);

return ice_ptp_settime64(info, (const struct timespec64 *)&now);
Expand Down

0 comments on commit b3615ea

Please sign in to comment.