From patchwork Mon Mar 20 16:13:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 72271 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1315400wrt; Mon, 20 Mar 2023 09:38:08 -0700 (PDT) X-Google-Smtp-Source: AK7set9opHQhGaxhPpk9my/8w4wrECpBX+wzRnFNMoJsy5qf2bMdvYa6VvodLV46i7UFrd2fao1a X-Received: by 2002:a17:90b:3884:b0:23f:5273:1ae0 with SMTP id mu4-20020a17090b388400b0023f52731ae0mr14119870pjb.45.1679330288543; Mon, 20 Mar 2023 09:38:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679330288; cv=none; d=google.com; s=arc-20160816; b=lfuQScfsZmi94Srbz8i5D3+LJARJ/j7MQudLGtWo06od6kvI3f6Q/O9zm3CvfKfBRg kIydwO+NOl9LaS3aQkgSS/ZxLrIqAwFnT8IRZcRdsSGRnaUXFd7njScUeceWW/+rHgGF SfeZRxD4WJ9MaBmQxeu7mIH+pJ1t08yfJcuQQJw3AAsKAqhkBhGWeFvu/CMTDQ9G9mIH 23ky5v+j4TavngaAF8Ok4njCZTtmPLX1OJ3wZCRbxlRDusLDQu6YP+fglL0dgR5DifbU QJLKJ/tEe3vevHBIoqJEwKMpWQDru6BSwutOyLDq8Eq3/QUGZEdEIopZVU00REHo0vdj kO4g== 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 :message-id:date:subject:cc:to:from; bh=3Z832aIKH/zbNWitEUgkS4jzDTxiKaxi8wdWO2LnuGs=; b=wXH73pN/DF/4JX9bTNspeihDqH+gBp27z3OfmMT00+Luvw6GcEQDZOghtGCQxa2oHJ F8dv0Xc44dmBglrWOxT9agRC7yahs7Nlv64Lp9tHfMQ/URvlweDQ/PaoyDS2xpILYk9l qJfj/NAm5mwyGGn2xVi60cwoTisDJD1K7KkLxfnQzOhNmk4eFZAxsTe3LUZV2klE+Fss 3DpAaX+rnJkVnnX5Mjpk7/+HxTtNoBxLDLl1HwPj0qaBBw4IFn1bRq0gbijNDNl38Ffg vhAlOdxwHB5pHonEs6vZdVdKXFRkfcOWPQv5b3updZRSMwy8sTHPUa9EvBmYkPu3Lqgs gAGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o6-20020a17090a678600b00233b40ad95dsi10101326pjj.177.2023.03.20.09.37.56; Mon, 20 Mar 2023 09:38:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232431AbjCTQVu (ORCPT + 99 others); Mon, 20 Mar 2023 12:21:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232370AbjCTQVd (ORCPT ); Mon, 20 Mar 2023 12:21:33 -0400 Received: from smtp.smtpout.orange.fr (smtp-21.smtpout.orange.fr [80.12.242.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F2141ACDA for ; Mon, 20 Mar 2023 09:14:13 -0700 (PDT) Received: from localhost.localdomain ([109.190.253.11]) by smtp.orange.fr with ESMTPA id eI9ApRTg9HAQ0eI9Bp8cwS; Mon, 20 Mar 2023 17:14:11 +0100 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 20 Mar 2023 17:14:11 +0100 X-ME-IP: 109.190.253.11 From: Christophe JAILLET To: amitkarwar@gmail.com, siva8118@gmail.com, kvalo@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH net-next] rsi: Slightly simplify rsi_set_channel() Date: Mon, 20 Mar 2023 17:13:42 +0100 Message-Id: <29bf0296bd939e3f6952272bfdcc73b22edbc374.1679328588.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760905436270935724?= X-GMAIL-MSGID: =?utf-8?q?1760905436270935724?= There is no point in allocating 'skb' and then freeing it if !channel. Make the sanity check first to slightly simplify the code. Signed-off-by: Christophe JAILLET Reviewed-by: Simon Horman --- drivers/net/wireless/rsi/rsi_91x_mgmt.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/rsi/rsi_91x_mgmt.c b/drivers/net/wireless/rsi/rsi_91x_mgmt.c index c14689266fec..be9ac252f804 100644 --- a/drivers/net/wireless/rsi/rsi_91x_mgmt.c +++ b/drivers/net/wireless/rsi/rsi_91x_mgmt.c @@ -1127,6 +1127,9 @@ int rsi_set_channel(struct rsi_common *common, rsi_dbg(MGMT_TX_ZONE, "%s: Sending scan req frame\n", __func__); + if (!channel) + return 0; + skb = dev_alloc_skb(frame_len); if (!skb) { rsi_dbg(ERR_ZONE, "%s: Failed in allocation of skb\n", @@ -1134,10 +1137,6 @@ int rsi_set_channel(struct rsi_common *common, return -ENOMEM; } - if (!channel) { - dev_kfree_skb(skb); - return 0; - } memset(skb->data, 0, frame_len); chan_cfg = (struct rsi_chan_config *)skb->data;