From patchwork Thu Sep 12 12:57:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 274551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 878252C0177 for ; Thu, 12 Sep 2013 22:58:14 +1000 (EST) Received: from localhost ([::1]:41815 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VK6TL-00016B-RV for incoming@patchwork.ozlabs.org; Thu, 12 Sep 2013 08:58:11 -0400 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 Received: from localhost (dhcp-200-247.str.redhat.com [10.33.200.247]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r8CCvbTQ006055 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Thu, 12 Sep 2013 08:57:38 -0400 From: Max Reitz To: qemu-devel@nongnu.org Date: Thu, 12 Sep 2013 14:57:27 +0200 Message-Id: <1378990647-14079-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz Subject: [Qemu-devel] [PATCH] block: Assert validity of BdrvActionOps X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Eric Blake --- 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;