Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98a648e1 authored by Johannes Berg's avatar Johannes Berg Committed by Wey-Yi Guy
Browse files

iwlagn: verify mutex held for sync commands



Emmanuel noticed that there's no explicit checking
that prevents the driver from attempting to issue
multiple synchronous commands at the same time and
wrote a patch to check. However, his patch warns
only if a collision actually happened, an unlikely
thing since the driver mutex should be held for
synchronous command submissions.

So instead of checking that a collision happened
add a check that the mutex is held which ensures
that collisions can't happen.

Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarWey-Yi Guy <wey-yi.w.guy@intel.com>
parent 9a4ba833
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -1301,7 +1301,6 @@ struct iwl_priv {


	/* command queue number */
	/* command queue number */
	u8 cmd_queue;
	u8 cmd_queue;
	u8 last_sync_cmd_id;


	/* max number of station keys */
	/* max number of station keys */
	u8 sta_key_max_num;
	u8 sta_key_max_num;
+3 −10
Original line number Original line Diff line number Diff line
@@ -171,6 +171,8 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
	int cmd_idx;
	int cmd_idx;
	int ret;
	int ret;


	lockdep_assert_held(&priv->mutex);

	if (WARN_ON(cmd->flags & CMD_ASYNC))
	if (WARN_ON(cmd->flags & CMD_ASYNC))
		return -EINVAL;
		return -EINVAL;


@@ -181,16 +183,7 @@ int iwl_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd)
	IWL_DEBUG_INFO(priv, "Attempting to send sync command %s\n",
	IWL_DEBUG_INFO(priv, "Attempting to send sync command %s\n",
			get_cmd_string(cmd->id));
			get_cmd_string(cmd->id));


	if (test_and_set_bit(STATUS_HCMD_ACTIVE, &priv->status)) {
	set_bit(STATUS_HCMD_ACTIVE, &priv->status);
		IWL_ERR(priv, "STATUS_HCMD_ACTIVE already set while sending %s"
			      ". Previous SYNC cmdn is %s\n",
			get_cmd_string(cmd->id),
			get_cmd_string(priv->last_sync_cmd_id));
		WARN_ON(1);
	} else {
		priv->last_sync_cmd_id = cmd->id;
	}

	IWL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n",
	IWL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n",
			get_cmd_string(cmd->id));
			get_cmd_string(cmd->id));