Skip to contentSkip to conversation

ice: check the return of ice_ptp_gettimex64

PATCH In review [email protected] 3 participants 3 messages Feb 14, 2022 – Feb 18, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: check the return of ice_ptp_gettimex64

From: Tom Rix <[email protected]>

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")
---
 drivers/net/ethernet/intel/ice/ice_ptp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +4 -1
index ae291d442539..000c39d163a2 100644
@@ -1533,9 +1533,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);
Signature · 1 line
2.26.3
#1 lore raw
Quoted 19 lines

-----Original Message-----
From: trix at redhat.com <[email protected]>
Sent: Monday, February 14, 2022 6:33 AM
To: Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; davem at davemloft.net; kuba at kernel.org; nathan at kernel.org; ndesaulniers at google.com; Keller, Jacob E <[email protected]>
Cc: intel-wired-lan at lists.osuosl.org; netdev at vger.kernel.org; linux- kernel at vger.kernel.org; llvm at lists.linux.dev; Tom Rix <[email protected]>
Subject: [PATCH] ice: check the return of ice_ptp_gettimex64

From: Tom Rix <[email protected]>

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,

Quoted 8 lines
                                       ~~~~~~~~~~ ^

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")

Ahhh yep. Good fix. Thanks!

Quoted 26 lines
---
 drivers/net/ethernet/intel/ice/ice_ptp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_ptp.c +4 -1
index ae291d442539..000c39d163a2 100644
@@ -1533,9 +1533,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);
--
2.26.3

Tested-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 28 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of trix at redhat.com
Sent: Monday, February 14, 2022 8:03 PM
To: Brandeburg, Jesse <[email protected]>; Nguyen, Anthony L <[email protected]>; davem at davemloft.net; kuba at kernel.org; nathan at kernel.org; ndesaulniers at google.com; Keller, Jacob E <[email protected]>
Cc: netdev at vger.kernel.org; llvm at lists.linux.dev; intel-wired- lan at lists.osuosl.org; linux-kernel at vger.kernel.org; Tom Rix <[email protected]>
Subject: [Intel-wired-lan] [PATCH] ice: check the return of ice_ptp_gettimex64

From: Tom Rix <[email protected]>

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.

Quoted 7 lines
Fixes 06c16d89d2cb ("ice: register 1588 PTP clock device object for E810

devices")

---
 drivers/net/ethernet/intel/ice/ice_ptp.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)