Skip to content

Commit fe0984d

Browse files
arndbjmberg-intel
authored andcommitted
cfg80211: track time using boottime
The cfg80211 layer uses get_seconds() to read the current time in its supend handling. This function is deprecated because of the 32-bit time_t overflow, and it can cause unexpected behavior when the time changes due to settimeofday() calls or leap second updates. In many cases, we want to use monotonic time instead, however cfg80211 explicitly tracks the time spent in suspend, so this changes the driver over to use ktime_get_boottime_seconds(), which is slightly slower, but not used in a fastpath here. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 8ba6731 commit fe0984d

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎net/wireless/core.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct cfg80211_registered_device {
7676
struct cfg80211_scan_request *scan_req; /* protected by RTNL */
7777
struct sk_buff *scan_msg;
7878
struct list_head sched_scan_req_list;
79-
unsigned long suspend_at;
79+
time64_t suspend_at;
8080
struct work_struct scan_done_wk;
8181

8282
struct genl_info *cur_cmd_info;

‎net/wireless/sysfs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int wiphy_suspend(struct device *dev)
102102
struct cfg80211_registered_device *rdev = dev_to_rdev(dev);
103103
int ret = 0;
104104

105-
rdev->suspend_at = get_seconds();
105+
rdev->suspend_at = ktime_get_boottime_seconds();
106106

107107
rtnl_lock();
108108
if (rdev->wiphy.registered) {
@@ -130,7 +130,7 @@ static int wiphy_resume(struct device *dev)
130130
int ret = 0;
131131

132132
/* Age scan results with time spent in suspend */
133-
cfg80211_bss_age(rdev, get_seconds() - rdev->suspend_at);
133+
cfg80211_bss_age(rdev, ktime_get_boottime_seconds() - rdev->suspend_at);
134134

135135
rtnl_lock();
136136
if (rdev->wiphy.registered && rdev->ops->resume)

0 commit comments

Comments
 (0)