From f0507110baaf7d36b4bbf364510ec54b61af417d Mon Sep 17 00:00:00 2001 From: Surya Prakash Sivaraj Date: Thu, 13 May 2021 17:37:36 +0530 Subject: [PATCH] qcacld-3.0: Validate the duration and interval for P2P_SET_NOA The following are the firmware expectations for the parameters through p2p_set_noa: If count > 1 , the duration should be smaller than interval. If count = 1, the duration can be same or smaller as interval. Hence, set the duration as interval if it is configured greater than interval. This commit adds the checks accordingly. Fails the command if the above conditions do not pass. Change-Id: Ic273b0167c3551cd4b21d4c6dc7f31ba5329bebc CRs-Fixed: 2941170 --- core/hdd/src/wlan_hdd_p2p.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/hdd/src/wlan_hdd_p2p.c b/core/hdd/src/wlan_hdd_p2p.c index 62f4f05aa6b6..fbad35b350d7 100644 --- a/core/hdd/src/wlan_hdd_p2p.c +++ b/core/hdd/src/wlan_hdd_p2p.c @@ -511,6 +511,7 @@ int hdd_set_p2p_noa(struct net_device *dev, uint8_t *command) hdd_debug("P2P_SET GO noa: count=%d interval=%d duration=%d", count, interval, duration); duration = MS_TO_TU_MUS(duration); + interval = MS_TO_TU_MUS(interval); /* PS Selection * Periodic noa (2) * Single NOA (4) @@ -518,15 +519,21 @@ int hdd_set_p2p_noa(struct net_device *dev, uint8_t *command) noa.opp_ps = 0; noa.ct_window = 0; if (count == 1) { + if (duration > interval) + duration = interval; noa.duration = 0; noa.single_noa_duration = duration; noa.ps_selection = P2P_POWER_SAVE_TYPE_SINGLE_NOA; } else { + if (duration >= interval) { + hdd_err("Duration should be less than interval"); + return -EINVAL; + } noa.duration = duration; noa.single_noa_duration = 0; noa.ps_selection = P2P_POWER_SAVE_TYPE_PERIODIC_NOA; } - noa.interval = MS_TO_TU_MUS(interval); + noa.interval = interval; noa.count = count; noa.vdev_id = adapter->vdev_id;