From nobody Mon Apr 6 11:51:44 2026 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D92C313523 for ; Thu, 19 Mar 2026 12:08:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773922095; cv=none; b=dbKBYHNlcZ3EUeKIYAEs0pydPhngi1raG13fd5EuPnHDTFCLJX2dzt3FjKzFplhIR6E8iN29p8Pn2ujG3Hc4RsqGQwsu1btKfPYxzQhRNKgBidwFDKAbQbH8ObdCPuFcuRh/oW5HScRaWK0WkaALeLx/l8bBzGl4C1KcdUbzPag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773922095; c=relaxed/simple; bh=Mm2JoOYHeAzZx9kr9Ry9JGjqg/aR1jHAbQSKdbYCEC8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mAUAqJcSY6Xvg+CzhqTCY0WDhFk0qzicKQDGFMgulKTMvusrrmOTJ+PS/eys87fOVy8zY9INf3fHaMAS7PE0I2iE4uRp1DcTtdyT/QFQiv/DbZTKhMza5cTc2C4btQPpN2reOCR3wnhf1ZITIKyEu35TC1EtmhABnjWT+HXWkgk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Kq1hXhMe; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Kq1hXhMe" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-82995242934so927642b3a.0 for ; Thu, 19 Mar 2026 05:08:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773922094; x=1774526894; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vLEQwe+yFifzvWKq9zD+rUJ5wFDkLzjc0ts/3dMIVm0=; b=Kq1hXhMeWwbfw0Kp6KwEpm0+wVX+qf9n9lwreu2wlixMKldl2zk20GojGV7TfhiqLe HdNQGbLkq7gvQlKvDb1h7eN4g+pcDwTce+UL7cCX2anQARyMpGUHEcWMkUatx0U8T3GT rPDkg/LTWSR3KijJ+O7uhimo8jQZePzq5A0fYcHL8rybME+SlfleHIAmZi0g8dfjs+r+ 7+aXc9+uarnKm196W/82VuarXELT6IYaKxpiOUxrOLjuN4TOEOPpMR4n5I2XGdOoR2cb HcIwQOUeZHLaq4gMZLH0tTLFZGNpWyx26EAyDVjnaKNWNrVEK3L0VYszRgc3ZkbG3HsC vGvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773922094; x=1774526894; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=vLEQwe+yFifzvWKq9zD+rUJ5wFDkLzjc0ts/3dMIVm0=; b=sKnLqklscFK5cIDAhgnqYbBApeTX6OK5V3pxTHgQU5z+t/ZuMCLjwM+X3RK/OrT0Td KFa5f4qabvcxnM+QbCMHFVoL8k5whDwRSWLyGMYxUa7fcXEuVnpaeKbdXzGAYMNxP8+M H6szmX9FzeVXGkHBGaBju6jkD9Mo5VtZzvA6uQAb46aR0kSiTiXQkF3SB4inxzZZB4/G kz1g2EUIiWqoxxE1mmhe4Swxfvcwa5QJY7pNZeeg9HZOapD0CqWJPJ1fXUxzsYYavZAX 9KZqfK1E3xdbwId47Nt/WOiNTVQ5ZnUiSv1r0DaGSrqc6yS/LEpDJUu29QhTg3v92V1s xTVw== X-Forwarded-Encrypted: i=1; AJvYcCWGZM4ZMogZc1MqIQrfa2QPPVxW7twYaoWtR1foH5DGOzY7fWTbCRQ/8qb+7pOryjp/NtwOCTZAVAhbKUo=@vger.kernel.org X-Gm-Message-State: AOJu0YyghmIA7vnRPyxmcWf+Ck3mTUAKO/rTeL72JEe+D/37tWpIy5Fm oV6Kh038eVkJlpsxNMzeexoP3SsVs7hfvRtQzGWx8dP1HpzwmRqmhmF8 X-Gm-Gg: ATEYQzyGV3q6Q66tq4oAV1EySStihfc9T6deOS/QLs4TdWZlM6hY84MMCYqSJw0xjGg MArMZcePWNrbIOmGY9REkBQLOyMwF+uP4PA6D33Yw8Y/lPuMWiskpX6MvJwyoCc6u5gEzUGsWd5 TQt3/Z6DcebazlFv8m0/FlmM8WJOO5P7lwCN1WtpP8v8oEviw0Lm/QY//GPtnBtASPfjOlCR6cU zAA6k67lA3pRWrX2ZxSE24wS3qzViaeh4Hu1E2in81BDaw6bbVordzwYiiugoZdtYIyqGr49MYf W5AbQ/DSBRDbRJy/TLrxjFk1YC97pd64I68pms0ywSAtd1XPjHuyPR58KYPbE7Yi+BreXdoUqb8 a4dfUGo784VxlEcJzF7h7Vx6gIQ3I+3KfejtXgVBD2KFIIwQ60aq4OVIblHs0RobUC4ExCx3jGG SIPcuWbNapWpfqwnaWOROtFptd/kzqBK/Ofd7G1/FvB3+nxWsQ8ZWWW5DS+sVhUsP14KAXfLHnV gpQX4f9TnBHJoySQ9AW/VGL11RJQ1nTeFNbJA== X-Received: by 2002:a05:6a00:4197:b0:824:b03f:2f65 with SMTP id d2e1a72fcca58-82a7a7e5f12mr2473045b3a.7.1773922093625; Thu, 19 Mar 2026 05:08:13 -0700 (PDT) Received: from starpt-K55VD.. (2001-b011-7803-1df1-b14e-6890-de2e-81d0.dynamic-ip6.hinet.net. [2001:b011:7803:1df1:b14e:6890:de2e:81d0]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82a6bee990dsm7108477b3a.52.2026.03.19.05.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Mar 2026 05:08:13 -0700 (PDT) From: Lin YuChen To: gregkh@linuxfoundation.org, dan.carpenter@linaro.org Cc: straube.linux@gmail.com, starpt.official@gmail.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/2] staging: rtl8723bs: use guard clause for stainfo check Date: Thu, 19 Mar 2026 20:07:37 +0800 Message-Id: <20260319120737.29692-3-starpt.official@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260319120737.29692-1-starpt.official@gmail.com> References: <20260319120737.29692-1-starpt.official@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Continue the refactor of rtw_aes_decrypt() by introducing a guard clause for the stainfo check. This allows the subsequent multicast and unicast decryption logic to be moved one indentation level to the left, further improving code readability. Signed-off-by: Lin YuChen --- v3: Use "return _FAIL" instead of "res =3D _FAIL; goto exit" for the stainfo guard clause. v3: Revert unrelated formatting and line-breaking changes (e.g., in netdev_dbg calls) to keep the diff focused only on indentation changes, as suggested by Dan Carpenter. v2: Split the refactoring into a separate patch to make it easier to verify logic changes. drivers/staging/rtl8723bs/core/rtw_security.c | 96 +++++++++---------- 1 file changed, 47 insertions(+), 49 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/stagin= g/rtl8723bs/core/rtw_security.c index 3c89e911ac2d..cf910c268bb3 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -1216,66 +1216,64 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *p= recvframe) if (prxattrib->encrypt !=3D _AES_) return _SUCCESS; stainfo =3D rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); - if (stainfo) { - if (is_multicast_ether_addr(prxattrib->ra)) { - static unsigned long start; - static u32 no_gkey_bc_cnt; - static u32 no_gkey_mc_cnt; - - if (!psecuritypriv->binstallGrpkey) { - res =3D _FAIL; + if (stainfo) + return _FAIL; + if (is_multicast_ether_addr(prxattrib->ra)) { + static unsigned long start; + static u32 no_gkey_bc_cnt; + static u32 no_gkey_mc_cnt; =20 - if (start =3D=3D 0) - start =3D jiffies; + if (!psecuritypriv->binstallGrpkey) { + res =3D _FAIL; =20 - if (is_broadcast_mac_addr(prxattrib->ra)) - no_gkey_bc_cnt++; - else - no_gkey_mc_cnt++; - - if (jiffies_to_msecs(jiffies - start) > 1000) { - if (no_gkey_bc_cnt || no_gkey_mc_cnt) { - netdev_dbg(padapter->pnetdev, - FUNC_ADPT_FMT " no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n", - FUNC_ADPT_ARG(padapter), - no_gkey_bc_cnt, - no_gkey_mc_cnt); - } - start =3D jiffies; - no_gkey_bc_cnt =3D 0; - no_gkey_mc_cnt =3D 0; - } + if (start =3D=3D 0) + start =3D jiffies; =20 - goto exit; - } + if (is_broadcast_mac_addr(prxattrib->ra)) + no_gkey_bc_cnt++; + else + no_gkey_mc_cnt++; =20 - if (no_gkey_bc_cnt || no_gkey_mc_cnt) { - netdev_dbg(padapter->pnetdev, - FUNC_ADPT_FMT " gkey installed. no_gkey_bc_cnt:%u, no_gkey_mc_cnt:= %u\n", - FUNC_ADPT_ARG(padapter), - no_gkey_bc_cnt, - no_gkey_mc_cnt); + if (jiffies_to_msecs(jiffies - start) > 1000) { + if (no_gkey_bc_cnt || no_gkey_mc_cnt) { + netdev_dbg(padapter->pnetdev, + FUNC_ADPT_FMT " no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%u\n", + FUNC_ADPT_ARG(padapter), + no_gkey_bc_cnt, + no_gkey_mc_cnt); + } + start =3D jiffies; + no_gkey_bc_cnt =3D 0; + no_gkey_mc_cnt =3D 0; } - start =3D 0; - no_gkey_bc_cnt =3D 0; - no_gkey_mc_cnt =3D 0; =20 - prwskey =3D psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; - if (psecuritypriv->dot118021XGrpKeyid !=3D prxattrib->key_index) { - res =3D _FAIL; - goto exit; - } - } else { - prwskey =3D &stainfo->dot118021x_UncstKey.skey[0]; + goto exit; } =20 - length =3D ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrl= en - prxattrib->iv_len; - - res =3D aes_decipher(prwskey, prxattrib->hdrlen, pframe, length); + if (no_gkey_bc_cnt || no_gkey_mc_cnt) { + netdev_dbg(padapter->pnetdev, + FUNC_ADPT_FMT " gkey installed. no_gkey_bc_cnt:%u, no_gkey_mc_cnt:%= u\n", + FUNC_ADPT_ARG(padapter), + no_gkey_bc_cnt, + no_gkey_mc_cnt); + } + start =3D 0; + no_gkey_bc_cnt =3D 0; + no_gkey_mc_cnt =3D 0; =20 + prwskey =3D psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; + if (psecuritypriv->dot118021XGrpKeyid !=3D prxattrib->key_index) { + res =3D _FAIL; + goto exit; + } } else { - res =3D _FAIL; + prwskey =3D &stainfo->dot118021x_UncstKey.skey[0]; } + + length =3D ((union recv_frame *)precvframe)->u.hdr.len - prxattrib->hdrle= n - prxattrib->iv_len; + + res =3D aes_decipher(prwskey, prxattrib->hdrlen, pframe, length); + exit: return res; } --=20 2.34.1