[virtmagma] Fix release context
For proper error handling, send the request even with invalid
context id.
Change-Id: I6c0b92f597af3e1eb95226006fd37accbc1e769b
diff --git a/drivers/virtio/virtio_magma.c b/drivers/virtio/virtio_magma.c
index f2acf12..1c3978f 100644
--- a/drivers/virtio/virtio_magma.c
+++ b/drivers/virtio/virtio_magma.c
@@ -729,10 +729,16 @@ static int virtmagma_command_magma_release_context(
object = get_connection_object(connection, request->context_id,
MAGMA_CONTEXT);
- if (!object)
- return -EINVAL;
+ // Send the call even if bad context_id; tests check that magma error
+ // is set.
ret = vq_out_send_sync(instance->vi, command);
+
+ if (object) {
+ hash_del(&object->node);
+ kfree(object);
+ }
+
if (ret)
return ret;
@@ -740,9 +746,6 @@ static int virtmagma_command_magma_release_context(
if (ret)
return ret;
- hash_del(&object->node);
- kfree(object);
-
return 0;
}