Merge "spcom: avoid race condition when handling commands"

This commit is contained in:
Linux Build Service Account 2017-07-06 23:41:20 -07:00 committed by Gerrit - the friendly Code Review server
commit 52a7c929b0

View file

@ -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;