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

Commit 52a7c929 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "spcom: avoid race condition when handling commands"

parents 807ef98e 5459f66a
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -245,7 +245,7 @@ struct spcom_device {
	int channel_count;

	/* private */
	struct mutex lock;
	struct mutex cmd_lock;

	/* Link state */
	struct completion link_state_changed;
@@ -1952,6 +1952,8 @@ static int spcom_handle_write(struct spcom_channel *ch,
	swap_id = htonl(cmd->cmd_id);
	memcpy(cmd_name, &swap_id, sizeof(int));

	mutex_lock(&spcom_dev->cmd_lock);

	pr_debug("cmd_id [0x%x] cmd_name [%s].\n", cmd_id, cmd_name);

	switch (cmd_id) {
@@ -1972,9 +1974,11 @@ static int spcom_handle_write(struct spcom_channel *ch,
		break;
	default:
		pr_err("Invalid Command Id [0x%x].\n", (int) cmd->cmd_id);
		return -EINVAL;
		ret = -EINVAL;
	}

	mutex_unlock(&spcom_dev->cmd_lock);

	return ret;
}

@@ -2675,7 +2679,7 @@ static int spcom_probe(struct platform_device *pdev)
		return -ENOMEM;

	spcom_dev = dev;
	mutex_init(&dev->lock);
	mutex_init(&spcom_dev->cmd_lock);
	init_completion(&dev->link_state_changed);
	spcom_dev->link_state = GLINK_LINK_STATE_DOWN;