From: Michael-CY Lee Date: Wed, 22 Nov 2023 03:02:37 +0000 (+0800) Subject: wifi: avoid offset calculation on NULL pointer X-Git-Tag: v6.1.74~94 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c880e1e38ea90a32ed6d261dc952128cfe7561f;p=thirdparty%2Fkernel%2Fstable.git wifi: avoid offset calculation on NULL pointer [ Upstream commit ef5828805842204dd0259ecfc132b5916c8a77ae ] ieee80211_he_6ghz_oper() can be passed a NULL pointer and checks for that, but already did the calculation to inside of it before. Move it after the check. Signed-off-by: Michael-CY Lee Link: https://lore.kernel.org/r/20231122030237.31276-1-michael-cy.lee@mediatek.com [rewrite commit message] Signed-off-by: Johannes Berg Signed-off-by: Sasha Levin --- diff --git a/include/linux/ieee80211.h b/include/linux/ieee80211.h index 870ae4cd82029..dce105f67b4d8 100644 --- a/include/linux/ieee80211.h +++ b/include/linux/ieee80211.h @@ -2658,12 +2658,14 @@ ieee80211_he_oper_size(const u8 *he_oper_ie) static inline const struct ieee80211_he_6ghz_oper * ieee80211_he_6ghz_oper(const struct ieee80211_he_operation *he_oper) { - const u8 *ret = (const void *)&he_oper->optional; + const u8 *ret; u32 he_oper_params; if (!he_oper) return NULL; + ret = (const void *)&he_oper->optional; + he_oper_params = le32_to_cpu(he_oper->he_oper_params); if (!(he_oper_params & IEEE80211_HE_OPERATION_6GHZ_OP_INFO))