Message ID | 1378990647-14079-1-git-send-email-mreitz@redhat.com |
---|---|
State | New |
Headers | show |
On 09/12/2013 06:57 AM, Max Reitz wrote: > 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. All of which would be a programmer bug, so assert is correct. > > Signed-off-by: Max Reitz <mreitz@redhat.com> > --- > blockdev.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/blockdev.c b/blockdev.c > index 07dac05..14a0bb1 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -1102,6 +1102,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); Bikeshedding: assert(ops->instance_size) is slightly less typing (but not enough to warrant a respin). Reviewed-by: Eric Blake <eblake@redhat.com>
Am 12.09.2013 um 14:57 hat Max Reitz geschrieben: > 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> Thanks, applied to the block branch. Kevin
diff --git a/blockdev.c b/blockdev.c index 07dac05..14a0bb1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1102,6 +1102,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;
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> --- blockdev.c | 2 ++ 1 file changed, 2 insertions(+)