Skip to content

Commit 09cab43

Browse files
Loic Poulainkvalo
authored andcommitted
wcn36xx: Fix max channels retrieval
Kernel test robot reported:drivers/net/wireless/ath/wcn36xx/smd.c:943:33: sparse: sparse: cast truncates bits from constant value (780 becomes 80) The 'channels' field is not a simple u8 array but an array of channel_params. Using sizeof for retrieving the max number of channels is then wrong. In practice, it was not an issue, because the sizeof returned value is 780, which is truncated in min_t (u8) to 80, which is the value we expect... Fix that properly using ARRAY_SIZE instead of sizeof. Fixes: d707f81 ("wcn36xx: Channel list update before hardware scan") Reported-by: kernel test robot <[email protected]> Signed-off-by: Loic Poulain <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9dcf680 commit 09cab43

File tree

1 file changed

+1
-1
lines changed
  • drivers/net/wireless/ath/wcn36xx

1 file changed

+1
-1
lines changed

drivers/net/wireless/ath/wcn36xx/smd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ int wcn36xx_smd_update_channel_list(struct wcn36xx *wcn, struct cfg80211_scan_re
944944

945945
INIT_HAL_MSG((*msg_body), WCN36XX_HAL_UPDATE_CHANNEL_LIST_REQ);
946946

947-
msg_body->num_channel = min_t(u8, req->n_channels, sizeof(msg_body->channels));
947+
msg_body->num_channel = min_t(u8, req->n_channels, ARRAY_SIZE(msg_body->channels));
948948
for (i = 0; i < msg_body->num_channel; i++) {
949949
struct wcn36xx_hal_channel_param *param = &msg_body->channels[i];
950950
u32 min_power = WCN36XX_HAL_DEFAULT_MIN_POWER;

0 commit comments

Comments
 (0)