Skip to contentSkip to conversation

9pfs: fix error path in pdu_submit()

PATCH In review Greg Kurz 2 participants 2 messages Dec 15, 2017 – Dec 20, 2017

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

PATCH 1/1 9pfs: fix error path in pdu_submit()

If we receive an unsupported request id, we first decide to return -ENOTSUPP to the client, but since the request id causes is_read_only_op() to return false, we change the error to be -EROFS if the fsdev is read-only. This doesn't make sense since we don't know what the client asked for.

This patch ensures that -EROFS can only be returned if the request id is supported.

---
 hw/9pfs/9p.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
hw/9pfs/9p.c +2 -4
index 76f90f2b7863..558efb41defd 100644
@@ -3473,14 +3473,12 @@ void pdu_submit(V9fsPDU *pdu, P9MsgHeader *hdr)
     if (pdu->id >= ARRAY_SIZE(pdu_co_handlers) ||
         (pdu_co_handlers[pdu->id] == NULL)) {
         handler = v9fs_op_not_supp;
+    } else if (is_ro_export(&s->ctx) && !is_read_only_op(pdu)) {
+        handler = v9fs_fs_ro;
     } else {
         handler = pdu_co_handlers[pdu->id];
     }
 
-    if (is_ro_export(&s->ctx) && !is_read_only_op(pdu)) {
-        handler = v9fs_fs_ro;
-    }
-
     qemu_co_queue_init(&pdu->complete);
     co = qemu_coroutine_create(handler, pdu);
     qemu_coroutine_enter(co);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Greg Kurz

If we receive an unsupported request id, we first decide to return -ENOTSUPP to the client, but since the request id causes is_read_only_op() to return false, we change the error to be -EROFS if the fsdev is read-only. This doesn't make sense since we don't know what the client asked for.

Quoted 8 lines

This patch ensures that -EROFS can only be returned if the request id is supported.

---
  hw/9pfs/9p.c |    6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org