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

Commit 139aacf7 authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman
Browse files

mei: fix read after read scenario



mei read always has to be preceded by write but
'write write read read' scenario should work as well.
In this case the offset is not zero but new read should
be initiated

Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 7131799b
Loading
Loading
Loading
Loading
+13 −11
Original line number Diff line number Diff line
@@ -214,19 +214,21 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
		goto out;
	}

	if (cl->read_cb && cl->read_cb->buf_idx > *offset) {
	if (cl->read_cb) {
		cb = cl->read_cb;
		/* read what left */
		if (cb->buf_idx > *offset)
			goto copy_buffer;
	} else if (cl->read_cb && cl->read_cb->buf_idx > 0 &&
		   cl->read_cb->buf_idx <= *offset) {
		cb = cl->read_cb;
		/* offset is beyond buf_idx we have no more data return 0 */
		if (cb->buf_idx > 0 && cb->buf_idx <= *offset) {
			rets = 0;
			goto free;
	} else if ((!cl->read_cb || !cl->read_cb->buf_idx) && *offset > 0) {
		}
		/* Offset needs to be cleaned for contiguous reads*/
		if (cb->buf_idx == 0 && *offset > 0)
			*offset = 0;
	} else if (*offset > 0) {
		*offset = 0;
		rets = 0;
		goto out;
	}

	err = mei_cl_read_start(cl, length);