Skip to content

Commit 521dc6c

Browse files
egrumbachjmberg-intel
authored andcommitted
iwlwiif: mvm: refactor iwl_mvm_notify_rx_queue
Instead of allocating memory for which we have an upper limit, use a small buffer on stack. Signed-off-by: Emmanuel Grumbach <[email protected]> Signed-off-by: Luca Coelho <[email protected]> Signed-off-by: Johannes Berg <[email protected]>
1 parent c61b655 commit 521dc6c

File tree

2 files changed

+9
-9
lines changed
  • drivers/net/wireless/intel/iwlwifi

2 files changed

+9
-9
lines changed

drivers/net/wireless/intel/iwlwifi/fw/api/rx.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,6 @@ struct iwl_rss_config_cmd {
776776
u8 indirection_table[IWL_RSS_INDIRECTION_TABLE_SIZE];
777777
} __packed; /* RSS_CONFIG_CMD_API_S_VER_1 */
778778

779-
#define IWL_MULTI_QUEUE_SYNC_MSG_MAX_SIZE 128
780779
#define IWL_MULTI_QUEUE_SYNC_SENDER_POS 0
781780
#define IWL_MULTI_QUEUE_SYNC_SENDER_MSK 0xf
782781

drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -465,18 +465,20 @@ static bool iwl_mvm_is_dup(struct ieee80211_sta *sta, int queue,
465465
int iwl_mvm_notify_rx_queue(struct iwl_mvm *mvm, u32 rxq_mask,
466466
const u8 *data, u32 count)
467467
{
468-
struct iwl_rxq_sync_cmd *cmd;
468+
u8 buf[sizeof(struct iwl_rxq_sync_cmd) +
469+
sizeof(struct iwl_mvm_rss_sync_notif)];
470+
struct iwl_rxq_sync_cmd *cmd = (void *)buf;
469471
u32 data_size = sizeof(*cmd) + count;
470472
int ret;
471473

472-
/* should be DWORD aligned */
473-
if (WARN_ON(count & 3 || count > IWL_MULTI_QUEUE_SYNC_MSG_MAX_SIZE))
474+
/*
475+
* size must be a multiple of DWORD
476+
* Ensure we don't overflow buf
477+
*/
478+
if (WARN_ON(count & 3 ||
479+
count > sizeof(struct iwl_mvm_rss_sync_notif)))
474480
return -EINVAL;
475481

476-
cmd = kzalloc(data_size, GFP_KERNEL);
477-
if (!cmd)
478-
return -ENOMEM;
479-
480482
cmd->rxq_mask = cpu_to_le32(rxq_mask);
481483
cmd->count = cpu_to_le32(count);
482484
cmd->flags = 0;
@@ -487,7 +489,6 @@ int iwl_mvm_notify_rx_queue(struct iwl_mvm *mvm, u32 rxq_mask,
487489
TRIGGER_RX_QUEUES_NOTIF_CMD),
488490
0, data_size, cmd);
489491

490-
kfree(cmd);
491492
return ret;
492493
}
493494

0 commit comments

Comments
 (0)