Skip to content

Commit

Permalink
mei: move write cb to completion on credentials failures
Browse files Browse the repository at this point in the history
The credentials handling was pushed to the write handlers
but error handling wasn't done properly.
Move write callbacks to completion queue to destroy them
and to notify a blocked writer about the failure

Fixes: 136698e (mei: push credentials inside the irq write handler)
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
ausyskin authored and gregkh committed Jan 4, 2017
1 parent 5026c9c commit e09ee85
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions drivers/misc/mei/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,

rets = first_chunk ? mei_cl_tx_flow_ctrl_creds(cl) : 1;
if (rets < 0)
return rets;
goto err;

if (rets == 0) {
cl_dbg(dev, cl, "No flow control credentials: not sending.\n");
Expand Down Expand Up @@ -1575,26 +1575,30 @@ int mei_cl_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
cb->buf.size, cb->buf_idx);

rets = mei_write_message(dev, &mei_hdr, buf->data + cb->buf_idx);
if (rets) {
cl->status = rets;
list_move_tail(&cb->list, &cmpl_list->list);
return rets;
}
if (rets)
goto err;

cl->status = 0;
cl->writing_state = MEI_WRITING;
cb->buf_idx += mei_hdr.length;
cb->completed = mei_hdr.msg_complete == 1;

if (first_chunk) {
if (mei_cl_tx_flow_ctrl_creds_reduce(cl))
return -EIO;
if (mei_cl_tx_flow_ctrl_creds_reduce(cl)) {
rets = -EIO;
goto err;
}
}

if (mei_hdr.msg_complete)
list_move_tail(&cb->list, &dev->write_waiting_list.list);

return 0;

err:
cl->status = rets;
list_move_tail(&cb->list, &cmpl_list->list);
return rets;
}

/**
Expand Down

0 comments on commit e09ee85

Please sign in to comment.