From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88C2A64AAD; Tue, 23 Jan 2024 00:54:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705971299; cv=none; b=L+j5lw2mlQe9AC+2JSIsF9zqJPJL9nrldW4uBLgaeCprg0WLSCcSOvSoRj+jL91NzGN46oLcHlJ8IpuyuAzSM0MO54EIJWdUsJVWQ7zMKdGSM8GtS8Oq1VQU+R5akuVRkoaMtU6UeG7N30hqotoLYQFqikNpisTqliDph1R/RKg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705971299; c=relaxed/simple; bh=NwGINAymK26xsbdc3Yk041/XumBbQgUTtriYUSr5lH8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s974lcMZ+RJjIvZuW6MN8ML4qP7/CJZlEjxlstSTRvTvy0y8sE7X4+kZeCg6WJZdA6sqw4Wezijcv+GRsnwA8pyH+CeodBFPNmdBXo4N5qKo6D2FYUnUQWKFhqmFfp68Wwo4n5ts+Fv1hyQRq62XI0NH9OiHkkohPoeg794CPqA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IhAie+eJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IhAie+eJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B04C2C433C7; Tue, 23 Jan 2024 00:54:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705971299; bh=NwGINAymK26xsbdc3Yk041/XumBbQgUTtriYUSr5lH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IhAie+eJAlSkLpX4iIwjYT3uQ+Hp662GTBFaccKAGeklyAtpjVrQvF2WXir13Sv4P H0tKapBO/QxffhZRmC1bvaFqzcbILOAOn/GEAzy0xuQZFc79sahB/8ku7+JkyfreT0 8+M7ZDm2ZeSovZKuML1v+3de3e5Ye/pHSDjAqRd4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Su Hui , Ping-Ke Shih , Kalle Valo , Sasha Levin Subject: [PATCH 5.10 130/286] wifi: rtlwifi: add calculate_bit_shift() Date: Mon, 22 Jan 2024 15:57:16 -0800 Message-ID: <20240122235737.150270702@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122235732.009174833@linuxfoundation.org> References: <20240122235732.009174833@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Su Hui [ Upstream commit 52221dfddbbfb5b4e029bb2efe9bb7da33ec1e46 ] There are many same functions like _rtl88e_phy_calculate_bit_shift(), _rtl92c_phy_calculate_bit_shift() and so on. And these functions can cause undefined bitwise shift behavior. Add calculate_bit_shift() to replace them and fix undefined behavior in subsequent patches. Signed-off-by: Su Hui Acked-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://msgid.link/20231219065739.1895666-2-suhui@nfschina.com Stable-dep-of: 969bc926f04b ("wifi: rtlwifi: rtl8188ee: phy: using calculate_bit_shift()") Signed-off-by: Sasha Levin --- drivers/net/wireless/realtek/rtlwifi/wifi.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h index fdccfd29fd61..a89e232d6963 100644 --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h @@ -3111,4 +3111,11 @@ static inline struct ieee80211_sta *rtl_find_sta(struct ieee80211_hw *hw, return ieee80211_find_sta(mac->vif, mac_addr); } +static inline u32 calculate_bit_shift(u32 bitmask) +{ + if (WARN_ON_ONCE(!bitmask)) + return 0; + + return __ffs(bitmask); +} #endif -- 2.43.0