Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp681363rwb; Wed, 26 Jul 2023 00:39:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlEdS3kBPFTLlSTotj5j/F1lQA9iPBvfO8cI/F3SLWI8IJh8EtzlslTblcaBrQHqA2a8GA9x X-Received: by 2002:a05:6a21:778a:b0:12c:e3c8:8c7 with SMTP id bd10-20020a056a21778a00b0012ce3c808c7mr1024342pzc.41.1690357151249; Wed, 26 Jul 2023 00:39:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690357151; cv=none; d=google.com; s=arc-20160816; b=a237Y4HZ4swH3ehJpCIQz/bG/RjLHiHVEJDUkb1zY+AtRrIFp3jnlqKNUprlSm/uHk nlwwJbBYlC6owktf+4VVF2FZK1dyH4Rfk2qVsVF26JV9P3Ra/gsh5wcpV0/rM5sBE4fL Fbo7qJOjkTP6A0DmdP9ijI9QuFyZdTk/Y1hEEbXnYBkv5SHNER5Y13Q5+OsCVd0JlZt8 8MLxxF8VOwlZbLALPuQ+FribB72FP1itiiBXHJRKIIq4Jazj5nBfUOhSHOxTQ4KmRPP2 LqzAsqxMqRJAo8JOM/L8E6w0ztDffJYGkN4JR774B9vzJK3PObhykOla0zc+g5ldPIEZ el0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Xekw69DB5UQpqiXmVWr1qk7CKBlJBthEe4TyQ0zSaEs=; fh=o3fNsMfyqDni024pe6cTlbw1vzPM6MJMk4keKHZ8Hfo=; b=AHB79SUV3+lfqagMZLDq8BA8qaDRQleaQ92NdogCK7tcqUxl/cxxzAtVR0H61P8swB 3hAQz5k0wEgvdY5Zvxu1il041mnnwhvWC7N5eI7zYbLgndVdVIFK+biAXvkdA5RXZ3av Qe2rtPPUU0vxEv4tKx+fsifwssjfSKb31AT6GEAFeaUJMbpVV/ziMD8dhKeI3uDvytDU 9kf37e4BH3D1Uc6YGhXR6OJ+MqSAsm/zBuiV8yHYMIo0vvp3YQLhSrxrL5KLqSOXsBwM WQKfdz4vQUHHpwSViRdSs2MEVza/+42IcJKi0KvD5iGApKhYmHRKZjP2X2I4SwFSO+GH 9smg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b="tCx4/XC2"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fc41-20020a056a002e2900b00653b5ab16c3si13406486pfb.265.2023.07.26.00.39.02; Wed, 26 Jul 2023 00:39:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b="tCx4/XC2"; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232539AbjGZHYS (ORCPT + 58 others); Wed, 26 Jul 2023 03:24:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232924AbjGZHX1 (ORCPT ); Wed, 26 Jul 2023 03:23:27 -0400 Received: from forward101b.mail.yandex.net (forward101b.mail.yandex.net [178.154.239.148]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C230C4204 for ; Wed, 26 Jul 2023 00:21:50 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-36.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-36.sas.yp-c.yandex.net [IPv6:2a02:6b8:c08:a497:0:640:fcbf:0]) by forward101b.mail.yandex.net (Yandex) with ESMTP id 6886760052; Wed, 26 Jul 2023 10:21:48 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-36.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id kLF1MPmWs8c0-TD3Eyigc; Wed, 26 Jul 2023 10:21:47 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1690356107; bh=Xekw69DB5UQpqiXmVWr1qk7CKBlJBthEe4TyQ0zSaEs=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=tCx4/XC2snK6Z9RLRpI/j+iOs1xIDF8CisHdr6eeDuZb9//gBxz1W/nQmtatuLOdy TFSC4xpLOa3d+ytruI2SglHy4jyDkLSFIR0on1x/dYWESwxVvlIT7lzDFdwE6o5d47 IL4bquOdiHGsoE5RZyzl209rJbIfLNja+xXTGp3w= Authentication-Results: mail-nwsmtp-smtp-production-main-36.sas.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Kalle Valo Cc: Brian Norris , linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH 2/5] wifi: mwifiex: drop BUG_ON() from TX error handling Date: Wed, 26 Jul 2023 10:20:53 +0300 Message-ID: <20230726072114.51964-2-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230726072114.51964-1-dmantipov@yandex.ru> References: <20230726072114.51964-1-dmantipov@yandex.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Remove 'BUG_ON()' from 'mwifiex_process_sta_txpd()' and 'mwifiex_process_uap_txpd()'. In case of insufficient headrom, issue warning and return NULL, which should be gracefully handled in 'mwifiex_process_tx()'. Also mark error handling branches with 'unlikely()' and simplify error messages (there is no need to use formatted output to print the value which is known to be zero). Signed-off-by: Dmitry Antipov --- drivers/net/wireless/marvell/mwifiex/sta_tx.c | 13 ++++++++----- drivers/net/wireless/marvell/mwifiex/uap_txrx.c | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/sta_tx.c b/drivers/net/wireless/marvell/mwifiex/sta_tx.c index 13c0e67ededf..5995a81f1ce9 100644 --- a/drivers/net/wireless/marvell/mwifiex/sta_tx.c +++ b/drivers/net/wireless/marvell/mwifiex/sta_tx.c @@ -39,14 +39,17 @@ void *mwifiex_process_sta_txpd(struct mwifiex_private *priv, u16 pkt_type, pkt_offset; int hroom = adapter->intf_hdr_len; - if (!skb->len) { - mwifiex_dbg(adapter, ERROR, - "Tx: bad packet length: %d\n", skb->len); + if (unlikely(!skb->len)) { + mwifiex_dbg(adapter, ERROR, "Tx: empty skb\n"); tx_info->status_code = -1; return skb->data; } - - BUG_ON(skb_headroom(skb) < MWIFIEX_MIN_DATA_HEADER_LEN); + if (unlikely(skb_headroom(skb) < MWIFIEX_MIN_DATA_HEADER_LEN)) { + mwifiex_dbg(adapter, ERROR, + "Tx: insufficient skb headroom: %u < %u\n", + skb_headroom(skb), MWIFIEX_MIN_DATA_HEADER_LEN); + return NULL; + } pkt_type = mwifiex_is_skb_mgmt_frame(skb) ? PKT_TYPE_MGMT : 0; diff --git a/drivers/net/wireless/marvell/mwifiex/uap_txrx.c b/drivers/net/wireless/marvell/mwifiex/uap_txrx.c index e495f7eaea03..ff953e8e7413 100644 --- a/drivers/net/wireless/marvell/mwifiex/uap_txrx.c +++ b/drivers/net/wireless/marvell/mwifiex/uap_txrx.c @@ -452,14 +452,17 @@ void *mwifiex_process_uap_txpd(struct mwifiex_private *priv, u16 pkt_type, pkt_offset; int hroom = adapter->intf_hdr_len; - if (!skb->len) { - mwifiex_dbg(adapter, ERROR, - "Tx: bad packet length: %d\n", skb->len); + if (unlikely(!skb->len)) { + mwifiex_dbg(adapter, ERROR, "Tx: empty skb\n"); tx_info->status_code = -1; return skb->data; } - - BUG_ON(skb_headroom(skb) < MWIFIEX_MIN_DATA_HEADER_LEN); + if (unlikely(skb_headroom(skb) < MWIFIEX_MIN_DATA_HEADER_LEN)) { + mwifiex_dbg(adapter, ERROR, + "Tx: insufficient skb headroom: %u < %u\n", + skb_headroom(skb), MWIFIEX_MIN_DATA_HEADER_LEN); + return NULL; + } pkt_type = mwifiex_is_skb_mgmt_frame(skb) ? PKT_TYPE_MGMT : 0; -- 2.41.0