From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42401) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK6Sz-00015r-SL for qemu-devel@nongnu.org; Thu, 12 Sep 2013 08:57:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VK6Sq-0003VQ-Ck for qemu-devel@nongnu.org; Thu, 12 Sep 2013 08:57:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23197) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK6Sq-0003VF-6B for qemu-devel@nongnu.org; Thu, 12 Sep 2013 08:57:40 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8CCvcVZ032635 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 12 Sep 2013 08:57:39 -0400 From: Max Reitz Date: Thu, 12 Sep 2013 14:57:27 +0200 Message-Id: <1378990647-14079-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH] block: Assert validity of BdrvActionOps List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 --- 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