* [Qemu-devel] [PATCH] block: Assert validity of BdrvActionOps
@ 2013-09-12 12:57 Max Reitz
2013-09-12 14:25 ` Eric Blake
2013-09-12 14:28 ` Kevin Wolf
0 siblings, 2 replies; 3+ messages in thread
From: Max Reitz @ 2013-09-12 12:57 UTC (permalink / raw)
To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi, Max Reitz
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(+)
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;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] block: Assert validity of BdrvActionOps
2013-09-12 12:57 [Qemu-devel] [PATCH] block: Assert validity of BdrvActionOps Max Reitz
@ 2013-09-12 14:25 ` Eric Blake
2013-09-12 14:28 ` Kevin Wolf
1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2013-09-12 14:25 UTC (permalink / raw)
To: Max Reitz; +Cc: Kevin Wolf, qemu-devel, Stefan Hajnoczi
[-- Attachment #1: Type: text/plain, Size: 1120 bytes --]
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>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] block: Assert validity of BdrvActionOps
2013-09-12 12:57 [Qemu-devel] [PATCH] block: Assert validity of BdrvActionOps Max Reitz
2013-09-12 14:25 ` Eric Blake
@ 2013-09-12 14:28 ` Kevin Wolf
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2013-09-12 14:28 UTC (permalink / raw)
To: Max Reitz; +Cc: qemu-devel, Stefan Hajnoczi
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-09-12 14:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-12 12:57 [Qemu-devel] [PATCH] block: Assert validity of BdrvActionOps Max Reitz
2013-09-12 14:25 ` Eric Blake
2013-09-12 14:28 ` Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).