]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
ice: check the return of ice_ptp_gettimex64
authorTom Rix <trix@redhat.com>
Mon, 14 Feb 2022 14:33:27 +0000 (06:33 -0800)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Fri, 18 Feb 2022 21:28:39 +0000 (13:28 -0800)
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: 06c16d89d2cb ("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>
drivers/net/ethernet/intel/ice/ice_ptp.c

index ae291d442539710d63e7dede50aea411fbc88ade..000c39d163a28e521c9a771b2824c3a05021a8e9 100644 (file)
@@ -1533,9 +1533,12 @@ exit:
 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);