diff mbox series

[v3,2/2] xenbus: req->err should be updated before req->state

Message ID 20200303221423.21962-2-dongli.zhang@oracle.com (mailing list archive)
State Accepted
Commit c5f13b8229ee4a3032080cab880cd2f40b3c213f
Headers show
Series [v3,1/2] xenbus: req->body should be updated before req->state | expand

Commit Message

Dongli Zhang March 3, 2020, 10:14 p.m. UTC
This patch adds the barrier to guarantee that req->err is always updated
before req->state.

Otherwise, read_reply() would not return ERR_PTR(req->err) but
req->body, when process_writes()->xb_write() is failed.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 drivers/xen/xenbus/xenbus_comms.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Julien Grall March 4, 2020, 1:50 p.m. UTC | #1
Hi,

On 03/03/2020 22:14, Dongli Zhang wrote:
> This patch adds the barrier to guarantee that req->err is always updated
> before req->state.
> 
> Otherwise, read_reply() would not return ERR_PTR(req->err) but
> req->body, when process_writes()->xb_write() is failed.
> 
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>

Reviewed-by: Julien Grall <jgrall@amazon.com>

Cheers,

---
Julien Grall
Boris Ostrovsky March 6, 2020, 11:13 a.m. UTC | #2
On 3/3/20 5:14 PM, Dongli Zhang wrote:
> This patch adds the barrier to guarantee that req->err is always updated
> before req->state.
>
> Otherwise, read_reply() would not return ERR_PTR(req->err) but
> req->body, when process_writes()->xb_write() is failed.
>
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>

Applied to for-linus-5.6b.

-boris
diff mbox series

Patch

diff --git a/drivers/xen/xenbus/xenbus_comms.c b/drivers/xen/xenbus/xenbus_comms.c
index 852ed161fc2a..eb5151fc8efa 100644
--- a/drivers/xen/xenbus/xenbus_comms.c
+++ b/drivers/xen/xenbus/xenbus_comms.c
@@ -397,6 +397,8 @@  static int process_writes(void)
 	if (state.req->state == xb_req_state_aborted)
 		kfree(state.req);
 	else {
+		/* write err, then update state */
+		virt_wmb();
 		state.req->state = xb_req_state_got_reply;
 		wake_up(&state.req->wq);
 	}