block: Assert validity of BdrvActionOps
authorMax Reitz <mreitz@redhat.com>
Thu, 12 Sep 2013 12:57:27 +0000 (14:57 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 12 Sep 2013 14:28:36 +0000 (16:28 +0200)
In qmp_transaction, assert that the BdrvActionOps to be used is actually
valid.

This assertion failing is very improbable, however, it might happen, if
a new TransactionActionKind is introduced "out of order" and the
actions[] array is not updated.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev.c

index 2ab236a82de707afc383520f44523501188c15d8..80605a2bac38be4fc90ed3d449af53168d3a39ec 100644 (file)
@@ -1286,6 +1286,8 @@ void qmp_transaction(TransactionActionList *dev_list, Error **errp)
         assert(dev_info->kind < ARRAY_SIZE(actions));
 
         ops = &actions[dev_info->kind];
+        assert(ops->instance_size > 0);
+
         state = g_malloc0(ops->instance_size);
         state->ops = ops;
         state->action = dev_info;