From patchwork Tue Aug 8 15:25:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 712329 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 4D13DC001B0 for ; Tue, 8 Aug 2023 15:58:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231246AbjHHP6b (ORCPT ); Tue, 8 Aug 2023 11:58:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231271AbjHHP5C (ORCPT ); Tue, 8 Aug 2023 11:57:02 -0400 Received: from forward203a.mail.yandex.net (forward203a.mail.yandex.net [178.154.239.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B776B5B95 for ; Tue, 8 Aug 2023 08:43:54 -0700 (PDT) Received: from forward100a.mail.yandex.net (forward100a.mail.yandex.net [IPv6:2a02:6b8:c0e:500:1:45:d181:d100]) by forward203a.mail.yandex.net (Yandex) with ESMTP id 3605748754 for ; Tue, 8 Aug 2023 18:27:03 +0300 (MSK) Received: from mail-nwsmtp-smtp-production-main-52.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-52.vla.yp-c.yandex.net [IPv6:2a02:6b8:c18:3c99:0:640:7c39:0]) by forward100a.mail.yandex.net (Yandex) with ESMTP id 98BEA46CF3; Tue, 8 Aug 2023 18:26:46 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-52.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id jQaGdD4DR0U0-3aoxAOA1; Tue, 08 Aug 2023 18:26:46 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1691508406; bh=HzciPL0UHcDSko7HoMRoD6OUrboLAVfN1ZdHJ8vTpHI=; h=Message-ID:Date:Cc:Subject:To:From; b=foz7XxK+1I4FGZZAtpJTxJV4hc5y6m0JmmHiHopwDnrswJ81M/zBfreoYn2OtB511 nSubwrMDlvTCbO9d9R81Kf2Z5DYG9nlTbqaCw32Wk1Tk+8axzMbSOmE50dcqXwuiRw vV6GuvJPiIawDy3zxSoV41gHim7JSKn5atRofTeI= Authentication-Results: mail-nwsmtp-smtp-production-main-52.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Jeff Johnson Cc: Kalle Valo , linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH 1/2] wifi: ath10k: do not ignore value returned by ath10k_wmi_peer_set_param() Date: Tue, 8 Aug 2023 18:25:35 +0300 Message-ID: <20230808152542.91117-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 Do not ignore value returned by 'ath10k_wmi_peer_set_param()' but rather propagate it as the return value of the 'ath10k_set_key()'. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 9cdd00575029 ("ath10k: fix TDLS peer TX data failure issue on encryped AP") Fixes: 382e51c139ef ("ath10k: set WMI_PEER_AUTHORIZE after a firmware crash") Signed-off-by: Dmitry Antipov --- drivers/net/wireless/ath/ath10k/mac.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c index 03e7bc5b6c0b..22e5ee151c49 100644 --- a/drivers/net/wireless/ath/ath10k/mac.c +++ b/drivers/net/wireless/ath/ath10k/mac.c @@ -6663,12 +6663,14 @@ static int ath10k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, spin_unlock_bh(&ar->data_lock); if (sta && sta->tdls) - ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr, - ar->wmi.peer_param->authorize, 1); - else if (sta && cmd == SET_KEY && (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) - ath10k_wmi_peer_set_param(ar, arvif->vdev_id, peer_addr, - ar->wmi.peer_param->authorize, 1); - + ret = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, sta->addr, + ar->wmi.peer_param->authorize, + 1); + else if (sta && cmd == SET_KEY && + (key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) + ret = ath10k_wmi_peer_set_param(ar, arvif->vdev_id, peer_addr, + ar->wmi.peer_param->authorize, + 1); exit: mutex_unlock(&ar->conf_mutex); return ret; From patchwork Tue Aug 8 15:25:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 711921 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 21DD3C001DE for ; Tue, 8 Aug 2023 16:00:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229761AbjHHQA6 (ORCPT ); Tue, 8 Aug 2023 12:00:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231210AbjHHP7Q (ORCPT ); Tue, 8 Aug 2023 11:59:16 -0400 Received: from forward201a.mail.yandex.net (forward201a.mail.yandex.net [178.154.239.92]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1AA1619B for ; Tue, 8 Aug 2023 08:44:27 -0700 (PDT) Received: from forward103a.mail.yandex.net (forward103a.mail.yandex.net [IPv6:2a02:6b8:c0e:500:1:45:d181:d103]) by forward201a.mail.yandex.net (Yandex) with ESMTP id C080C6260D for ; Tue, 8 Aug 2023 18:26:53 +0300 (MSK) Received: from mail-nwsmtp-smtp-production-main-52.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-52.vla.yp-c.yandex.net [IPv6:2a02:6b8:c18:3c99:0:640:7c39:0]) by forward103a.mail.yandex.net (Yandex) with ESMTP id 5B5C346CCB; Tue, 8 Aug 2023 18:26:49 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-52.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id jQaGdD4DR0U0-1itXzdJu; Tue, 08 Aug 2023 18:26:49 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1691508409; bh=vKyyIskcvzvxtICJ9oZ6sSURx4x8riR5qbMK/afw8go=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=DOrdk8HaRar6806WDYWR1gKpce5lUVpkkzg81JIa/2vWZ8ML2zzwnsdvtQxY0VVI7 KFA1yJu9MzBb/FeO8Ox3KQqG/EU6uZGH7tzEKAEhtUiYCqz3uGtPm3lcdDmjhOsfdg 9e/IRBJT//gxfyKwBB+ZjydoujV+UIqtw993uayE= Authentication-Results: mail-nwsmtp-smtp-production-main-52.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Jeff Johnson Cc: Kalle Valo , linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH 2/2] wifi: ath10k: consistently use kstrtoX_from_user() functions Date: Tue, 8 Aug 2023 18:25:36 +0300 Message-ID: <20230808152542.91117-2-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230808152542.91117-1-dmantipov@yandex.ru> References: <20230808152542.91117-1-dmantipov@yandex.ru> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Use 'kstrtoul_from_user()', 'kstrtouint_from_user()', and 'kstrtobool_from_user()' where appropriate and thus avoid some code duplication. Signed-off-by: Dmitry Antipov --- drivers/net/wireless/ath/ath10k/debug.c | 41 ++++++---------------- drivers/net/wireless/ath/ath10k/spectral.c | 26 +++++--------- 2 files changed, 19 insertions(+), 48 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c index f9518e1c9903..07a92f5296b6 100644 --- a/drivers/net/wireless/ath/ath10k/debug.c +++ b/drivers/net/wireless/ath/ath10k/debug.c @@ -1964,20 +1964,13 @@ static ssize_t ath10k_write_btcoex(struct file *file, size_t count, loff_t *ppos) { struct ath10k *ar = file->private_data; - char buf[32]; - size_t buf_size; int ret; bool val; u32 pdev_param; - buf_size = min(count, (sizeof(buf) - 1)); - if (copy_from_user(buf, ubuf, buf_size)) - return -EFAULT; - - buf[buf_size] = '\0'; - - if (kstrtobool(buf, &val) != 0) - return -EINVAL; + ret = kstrtobool_from_user(ubuf, count, &val); + if (ret) + return ret; if (!ar->coex_support) return -EOPNOTSUPP; @@ -2103,19 +2096,12 @@ static ssize_t ath10k_write_peer_stats(struct file *file, size_t count, loff_t *ppos) { struct ath10k *ar = file->private_data; - char buf[32]; - size_t buf_size; int ret; bool val; - buf_size = min(count, (sizeof(buf) - 1)); - if (copy_from_user(buf, ubuf, buf_size)) - return -EFAULT; - - buf[buf_size] = '\0'; - - if (kstrtobool(buf, &val) != 0) - return -EINVAL; + ret = kstrtobool_from_user(ubuf, count, &val); + if (ret) + return ret; mutex_lock(&ar->conf_mutex); @@ -2239,21 +2225,16 @@ static ssize_t ath10k_sta_tid_stats_mask_write(struct file *file, size_t count, loff_t *ppos) { struct ath10k *ar = file->private_data; - char buf[32]; - ssize_t len; u32 mask; + int ret; - len = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, len)) - return -EFAULT; - - buf[len] = '\0'; - if (kstrtoint(buf, 0, &mask)) - return -EINVAL; + ret = kstrtouint_from_user(user_buf, count, 0, &mask); + if (ret) + return ret; ar->sta_tid_stats_mask = mask; - return len; + return count; } static const struct file_operations fops_sta_tid_stats_mask = { diff --git a/drivers/net/wireless/ath/ath10k/spectral.c b/drivers/net/wireless/ath/ath10k/spectral.c index 68254a967ccb..2240994390ed 100644 --- a/drivers/net/wireless/ath/ath10k/spectral.c +++ b/drivers/net/wireless/ath/ath10k/spectral.c @@ -384,16 +384,11 @@ static ssize_t write_file_spectral_count(struct file *file, { struct ath10k *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 > 255) return -EINVAL; @@ -440,16 +435,11 @@ static ssize_t write_file_spectral_bins(struct file *file, { struct ath10k *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 < 64 || val > SPECTRAL_ATH10K_MAX_NUM_BINS) return -EINVAL;