From patchwork Thu Aug 24 07:50:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 13363665 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47176C71145 for ; Thu, 24 Aug 2023 07:55:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236732AbjHXHzY (ORCPT ); Thu, 24 Aug 2023 03:55:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234950AbjHXHzA (ORCPT ); Thu, 24 Aug 2023 03:55:00 -0400 Received: from forward100c.mail.yandex.net (forward100c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1A591709 for ; Thu, 24 Aug 2023 00:54:52 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:1e2b:0:640:94b5:0]) by forward100c.mail.yandex.net (Yandex) with ESMTP id BC170600E1; Thu, 24 Aug 2023 10:54:50 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id nsFdET9WwmI0-GTj9EgxE; Thu, 24 Aug 2023 10:54:49 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1692863690; bh=gRxIt5Uc0nHGnrNXrZxMBAiIJgwTs4LCIPesCrXLLdY=; h=Message-ID:Date:Cc:Subject:To:From; b=jAIcYWqMJU2dYQ4uxo6zyyzgGClzws7W3ZNuwpf3h6Fx1gq1csdF28/xsTLg12FEb CtYsOhB+k18Vxibb3oUBgxddU1voo/QnlKmf7VQhsRmqo1KnVvG1pCemfik61q9qEi fQbU7NYlruEqmgzQEiAJkclTcVnH+P9KvfEbP80g= Authentication-Results: mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Jeff Johnson Cc: Kalle Valo , Tom Rix , linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, ath11k@lists.infradead.org, Dmitry Antipov Subject: [PATCH 1/5] wifi: ath11k: drop redundant check in ath11k_dp_rx_mon_dest_process() Date: Thu, 24 Aug 2023 10:50:44 +0300 Message-ID: <20230824075121.121144-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org In 'ath11k_dp_rx_mon_dest_process()', 'mon_dst_srng' points to a member of 'srng_list', which is a fixed-size array inside 'struct ath11k_hal'. This way, if 'ring_id' is valid (i. e. between 0 and HAL_SRNG_RING_ID_MAX - 1 inclusive), 'mon_dst_srng' can't be NULL and so relevant check may be dropped. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Dmitry Antipov Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath11k/dp_rx.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index 1e488eed282b..3f315547878a 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -5097,13 +5097,6 @@ static void ath11k_dp_rx_mon_dest_process(struct ath11k *ar, int mac_id, mon_dst_srng = &ar->ab->hal.srng_list[ring_id]; - if (!mon_dst_srng) { - ath11k_warn(ar->ab, - "HAL Monitor Destination Ring Init Failed -- %p", - mon_dst_srng); - return; - } - spin_lock_bh(&pmon->mon_lock); ath11k_hal_srng_access_begin(ar->ab, mon_dst_srng); From patchwork Thu Aug 24 07:50:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 13363668 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BFFBC71145 for ; Thu, 24 Aug 2023 07:56:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234950AbjHXHz5 (ORCPT ); Thu, 24 Aug 2023 03:55:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236774AbjHXHz0 (ORCPT ); Thu, 24 Aug 2023 03:55:26 -0400 Received: from forward103c.mail.yandex.net (forward103c.mail.yandex.net [IPv6:2a02:6b8:c03:500:1:45:d181:d103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04E74170C for ; Thu, 24 Aug 2023 00:55:23 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:1e2b:0:640:94b5:0]) by forward103c.mail.yandex.net (Yandex) with ESMTP id BA0BC603D4; Thu, 24 Aug 2023 10:54:51 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id nsFdET9WwmI0-OEH6mo4p; Thu, 24 Aug 2023 10:54:50 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1692863690; bh=AfYkJSCKHAqWsERHvZQ7Utd958ZltNw48aNsHiisNYc=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Ooo38xcoZdB3Mh4BLrUOEzSsX8KUNXSRldh68JQ9Gi/bJO6N6MJGaniWKgRMqRY/H wjmCmgsZSkzWgqbc19J5Qx6m/qghgLHgbRBkTEwf6GVEJUMX90NtDMSpEjzaMO4Q1Y VkILn07txt1ma8b/Uw3Qq/wKNswrYyLSeDAX5V00= Authentication-Results: mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Jeff Johnson Cc: Kalle Valo , Tom Rix , linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, ath11k@lists.infradead.org, Dmitry Antipov Subject: [PATCH 2/5] wifi: ath11k: remove unused members of 'struct ath11k_base' Date: Thu, 24 Aug 2023 10:50:45 +0300 Message-ID: <20230824075121.121144-2-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824075121.121144-1-dmantipov@yandex.ru> References: <20230824075121.121144-1-dmantipov@yandex.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Remove set but otherwise unused 'wlan_init_status' and 'wmi_ready' members of 'struct ath11k_base', adjust 'ath11k_wmi_tlv_rdy_parse()' accordingly. Signed-off-by: Dmitry Antipov Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath11k/core.h | 2 -- drivers/net/wireless/ath/ath11k/wmi.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index b04447762483..650972f9d146 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -901,8 +901,6 @@ struct ath11k_base { struct list_head peers; wait_queue_head_t peer_mapping_wq; u8 mac_addr[ETH_ALEN]; - bool wmi_ready; - u32 wlan_init_status; int irq_num[ATH11K_IRQ_NUM_MAX]; struct ath11k_ext_irq_grp ext_irq_grp[ATH11K_EXT_IRQ_GRP_NUM_MAX]; struct ath11k_targ_cap target_caps; diff --git a/drivers/net/wireless/ath/ath11k/wmi.c b/drivers/net/wireless/ath/ath11k/wmi.c index 23ad6825e5be..a5cf97368a14 100644 --- a/drivers/net/wireless/ath/ath11k/wmi.c +++ b/drivers/net/wireless/ath/ath11k/wmi.c @@ -7222,14 +7222,12 @@ static int ath11k_wmi_tlv_rdy_parse(struct ath11k_base *ab, u16 tag, u16 len, memset(&fixed_param, 0, sizeof(fixed_param)); memcpy(&fixed_param, (struct wmi_ready_event *)ptr, min_t(u16, sizeof(fixed_param), len)); - ab->wlan_init_status = fixed_param.ready_event_min.status; rdy_parse->num_extra_mac_addr = fixed_param.ready_event_min.num_extra_mac_addr; ether_addr_copy(ab->mac_addr, fixed_param.ready_event_min.mac_addr.addr); ab->pktlog_defs_checksum = fixed_param.pktlog_defs_checksum; - ab->wmi_ready = true; break; case WMI_TAG_ARRAY_FIXED_STRUCT: addr_list = (struct wmi_mac_addr *)ptr; From patchwork Thu Aug 24 07:50:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 13363666 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 815EDC7EE43 for ; Thu, 24 Aug 2023 07:55:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236627AbjHXHzX (ORCPT ); Thu, 24 Aug 2023 03:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235481AbjHXHzA (ORCPT ); Thu, 24 Aug 2023 03:55:00 -0400 Received: from forward100b.mail.yandex.net (forward100b.mail.yandex.net [178.154.239.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B67EE170D for ; Thu, 24 Aug 2023 00:54:54 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:1e2b:0:640:94b5:0]) by forward100b.mail.yandex.net (Yandex) with ESMTP id 6859360135; Thu, 24 Aug 2023 10:54:52 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id nsFdET9WwmI0-HwLOH6sP; Thu, 24 Aug 2023 10:54:51 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1692863691; bh=qXPc9WQi8jtJuPmLlZa3OkWLGJnQUKyL8ylyggIXN3A=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=mJ+aNj2/JL5/wG8219fWP9uNBivlCZ8FpalRTtxoiGGt/XrV9hodQD1Q2VMDzJHEO vcbBx6zMaDzOuuVjw8HS51vaYiZjIoitKoLq8fVJDMIM7mNjVJi2I4BhBzAUQ7/nAx nfodvXEofI40fOjA24wMXQ5Qpodb8IVOz2iQmbJk= Authentication-Results: mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Jeff Johnson Cc: Kalle Valo , Tom Rix , linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, ath11k@lists.infradead.org, Dmitry Antipov Subject: [PATCH 3/5] wifi: ath11k: simplify spectral pull functions Date: Thu, 24 Aug 2023 10:50:46 +0300 Message-ID: <20230824075121.121144-3-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824075121.121144-1-dmantipov@yandex.ru> References: <20230824075121.121144-1-dmantipov@yandex.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Since 'ath11k_spectral_pull_summary()' and 'ath11k_spectral_pull_search()' always returns 0, both of them may be converted to 'void' and 'ath11k_spectral_process_fft()' may be simplified accordingly. Signed-off-by: Dmitry Antipov Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath11k/spectral.c | 24 ++++++++-------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/spectral.c b/drivers/net/wireless/ath/ath11k/spectral.c index 705868198df4..97eb2a457685 100644 --- a/drivers/net/wireless/ath/ath11k/spectral.c +++ b/drivers/net/wireless/ath/ath11k/spectral.c @@ -470,10 +470,10 @@ static const struct file_operations fops_scan_bins = { .llseek = default_llseek, }; -static int ath11k_spectral_pull_summary(struct ath11k *ar, - struct wmi_dma_buf_release_meta_data *meta, - struct spectral_summary_fft_report *summary, - struct ath11k_spectral_summary_report *report) +static void ath11k_spectral_pull_summary(struct ath11k *ar, + struct wmi_dma_buf_release_meta_data *meta, + struct spectral_summary_fft_report *summary, + struct ath11k_spectral_summary_report *report) { report->timestamp = __le32_to_cpu(summary->timestamp); report->agc_total_gain = FIELD_GET(SPECTRAL_SUMMARY_INFO0_AGC_TOTAL_GAIN, @@ -500,13 +500,11 @@ static int ath11k_spectral_pull_summary(struct ath11k *ar, __le32_to_cpu(summary->info2)); memcpy(&report->meta, meta, sizeof(*meta)); - - return 0; } -static int ath11k_spectral_pull_search(struct ath11k *ar, - struct spectral_search_fft_report *search, - struct ath11k_spectral_search_report *report) +static void ath11k_spectral_pull_search(struct ath11k *ar, + struct spectral_search_fft_report *search, + struct ath11k_spectral_search_report *report) { report->timestamp = __le32_to_cpu(search->timestamp); report->detector_id = FIELD_GET(SPECTRAL_FFT_REPORT_INFO0_DETECTOR_ID, @@ -531,8 +529,6 @@ static int ath11k_spectral_pull_search(struct ath11k *ar, __le32_to_cpu(search->info2)); report->rel_pwr_db = FIELD_GET(SPECTRAL_FFT_REPORT_INFO2_REL_PWR_DB, __le32_to_cpu(search->info2)); - - return 0; } static u8 ath11k_spectral_get_max_exp(s8 max_index, u8 max_magnitude, @@ -629,11 +625,7 @@ int ath11k_spectral_process_fft(struct ath11k *ar, return ret; } - ret = ath11k_spectral_pull_search(ar, data, &search); - if (ret) { - ath11k_warn(ab, "failed to pull search report %d\n", ret); - return ret; - } + ath11k_spectral_pull_search(ar, data, &search); chan_width_mhz = summary->meta.ch_width; From patchwork Thu Aug 24 07:50:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 13363664 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DEB1C7113B for ; Thu, 24 Aug 2023 07:55:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235528AbjHXHzX (ORCPT ); Thu, 24 Aug 2023 03:55:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235207AbjHXHzA (ORCPT ); Thu, 24 Aug 2023 03:55:00 -0400 Received: from forward100c.mail.yandex.net (forward100c.mail.yandex.net [178.154.239.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C963E10FF for ; Thu, 24 Aug 2023 00:54:54 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:1e2b:0:640:94b5:0]) by forward100c.mail.yandex.net (Yandex) with ESMTP id 24483600FD; Thu, 24 Aug 2023 10:54:53 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id nsFdET9WwmI0-OPLZSoHf; Thu, 24 Aug 2023 10:54:52 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1692863692; bh=6NdYX2kixUoSH55JuKhY1SO/fR7GYU/C2rIRwedWVkU=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=XZ++PEfEK0ZpaFblRX3KQPGyWtXtZDhJZo0YrZ+9tvYrEuOGFjJl8ccbHwoYAl+Nu NjQGHH/xbRFuO4JtMWO6V2TsDKfgAxCQDAFRvTFLz0sIYuZiKUPHbPajmTZ7onZOwI MR2CE/Qc+d815TFFN9XgmQ0eB7m4e4k7pnyn8iRs= Authentication-Results: mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Jeff Johnson Cc: Kalle Valo , Tom Rix , linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, ath11k@lists.infradead.org, Dmitry Antipov Subject: [PATCH 4/5] wifi: ath11k: use kstrtoul_from_user() where appropriate Date: Thu, 24 Aug 2023 10:50:47 +0300 Message-ID: <20230824075121.121144-4-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824075121.121144-1-dmantipov@yandex.ru> References: <20230824075121.121144-1-dmantipov@yandex.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Use 'kstrtoul_from_user()' in 'ath11k_write_file_spectral_count()' and 'ath11k_write_file_spectral_bins()' Signed-off-by: Dmitry Antipov Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath11k/spectral.c | 26 +++++++--------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/spectral.c b/drivers/net/wireless/ath/ath11k/spectral.c index 97eb2a457685..b5530e484507 100644 --- a/drivers/net/wireless/ath/ath11k/spectral.c +++ b/drivers/net/wireless/ath/ath11k/spectral.c @@ -382,16 +382,11 @@ static ssize_t ath11k_write_file_spectral_count(struct file *file, { struct ath11k *ar = file->private_data; unsigned long val; - char buf[32]; - ssize_t len; - - len = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; + ssize_t ret; - buf[len] = '\0'; - if (kstrtoul(buf, 0, &val)) - return -EINVAL; + ret = kstrtoul_from_user(user_buf, count, 0, &val); + if (ret) + return ret; if (val > ATH11K_SPECTRAL_SCAN_COUNT_MAX) return -EINVAL; @@ -437,16 +432,11 @@ static ssize_t ath11k_write_file_spectral_bins(struct file *file, { struct ath11k *ar = file->private_data; unsigned long val; - char buf[32]; - ssize_t len; - - len = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; + ssize_t ret; - buf[len] = '\0'; - if (kstrtoul(buf, 0, &val)) - return -EINVAL; + ret = kstrtoul_from_user(user_buf, count, 0, &val); + if (ret) + return ret; if (val < ATH11K_SPECTRAL_MIN_BINS || val > ar->ab->hw_params.spectral.max_fft_bins) From patchwork Thu Aug 24 07:50:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 13363667 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B6BEC7EE43 for ; Thu, 24 Aug 2023 07:56:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235895AbjHXHz6 (ORCPT ); Thu, 24 Aug 2023 03:55:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236838AbjHXHz1 (ORCPT ); Thu, 24 Aug 2023 03:55:27 -0400 Received: from forward103b.mail.yandex.net (forward103b.mail.yandex.net [178.154.239.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCB5F1709 for ; Thu, 24 Aug 2023 00:55:25 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:1e2b:0:640:94b5:0]) by forward103b.mail.yandex.net (Yandex) with ESMTP id B236360021; Thu, 24 Aug 2023 10:54:53 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id nsFdET9WwmI0-vGuxbnum; Thu, 24 Aug 2023 10:54:53 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1692863693; bh=t8sVbi/v2uwfYixKvm61hfDLATHIxHUnHyobe5AgHLw=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=K1LAwCOjdjvrzVCuEoLpzlWiN0bVe/9cyzWGSfeCC99J0pOeoMdjWXAa1bMoqvrPc 8mqPTroRt4HyekdyXGDwMoqqvr1tvId3aGe8anQioOOMt5S1DFa31jO3QbnvnUzkAc ZAzUvlxHxnj3Ha0VS5ltQEjkYQId4XenM5TC2jkw= Authentication-Results: mail-nwsmtp-smtp-production-main-59.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Jeff Johnson Cc: Kalle Valo , Tom Rix , linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, ath11k@lists.infradead.org, Dmitry Antipov Subject: [PATCH 5/5] wifi: ath11k: fix stack usage of ath11k_mac_op_remain_on_channel() Date: Thu, 24 Aug 2023 10:50:48 +0300 Message-ID: <20230824075121.121144-5-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824075121.121144-1-dmantipov@yandex.ru> References: <20230824075121.121144-1-dmantipov@yandex.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org When compiling with clang 16.0.6, I've noticed the following: drivers/net/wireless/ath/ath11k/mac.c:8900:12: warning: stack frame size (1032) exceeds limit (1024) in 'ath11k_mac_op_remain_on_channel' [-Wframe-larger-than] static int ath11k_mac_op_remain_on_channel(struct ieee80211_hw *hw, ^ 68/1032 (6.59%) spills, 964/1032 (93.41%) variables So switch to kzalloc()'ed instance of 'struct scan_req_params' and adjust the function in subject accordingly. Signed-off-by: Dmitry Antipov Acked-by: Jeff Johnson --- drivers/net/wireless/ath/ath11k/mac.c | 44 +++++++++++++++------------ 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 2aadf2c387b6..3e2983d30a5a 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -8905,7 +8905,7 @@ static int ath11k_mac_op_remain_on_channel(struct ieee80211_hw *hw, { struct ath11k *ar = hw->priv; struct ath11k_vif *arvif = (void *)vif->drv_priv; - struct scan_req_params arg; + struct scan_req_params *arg; int ret; u32 scan_time_msec; @@ -8937,27 +8937,31 @@ static int ath11k_mac_op_remain_on_channel(struct ieee80211_hw *hw, scan_time_msec = ar->hw->wiphy->max_remain_on_channel_duration * 2; - memset(&arg, 0, sizeof(arg)); - ath11k_wmi_start_scan_init(ar, &arg); - arg.num_chan = 1; - arg.chan_list = kcalloc(arg.num_chan, sizeof(*arg.chan_list), - GFP_KERNEL); - if (!arg.chan_list) { + arg = kzalloc(sizeof(*arg), GFP_KERNEL); + if (!arg) { ret = -ENOMEM; goto exit; } + ath11k_wmi_start_scan_init(ar, arg); + arg->num_chan = 1; + arg->chan_list = kcalloc(arg->num_chan, sizeof(*arg->chan_list), + GFP_KERNEL); + if (!arg->chan_list) { + ret = -ENOMEM; + goto free_arg; + } - arg.vdev_id = arvif->vdev_id; - arg.scan_id = ATH11K_SCAN_ID; - arg.chan_list[0] = chan->center_freq; - arg.dwell_time_active = scan_time_msec; - arg.dwell_time_passive = scan_time_msec; - arg.max_scan_time = scan_time_msec; - arg.scan_flags |= WMI_SCAN_FLAG_PASSIVE; - arg.scan_flags |= WMI_SCAN_FILTER_PROBE_REQ; - arg.burst_duration = duration; - - ret = ath11k_start_scan(ar, &arg); + arg->vdev_id = arvif->vdev_id; + arg->scan_id = ATH11K_SCAN_ID; + arg->chan_list[0] = chan->center_freq; + arg->dwell_time_active = scan_time_msec; + arg->dwell_time_passive = scan_time_msec; + arg->max_scan_time = scan_time_msec; + arg->scan_flags |= WMI_SCAN_FLAG_PASSIVE; + arg->scan_flags |= WMI_SCAN_FILTER_PROBE_REQ; + arg->burst_duration = duration; + + ret = ath11k_start_scan(ar, arg); if (ret) { ath11k_warn(ar->ab, "failed to start roc scan: %d\n", ret); @@ -8983,7 +8987,9 @@ static int ath11k_mac_op_remain_on_channel(struct ieee80211_hw *hw, ret = 0; free_chan_list: - kfree(arg.chan_list); + kfree(arg->chan_list); +free_arg: + kfree(arg); exit: mutex_unlock(&ar->conf_mutex); return ret;