From patchwork Fri Sep 13 11:51:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 274753 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 AC4872C00BE for ; Fri, 13 Sep 2013 22:03:50 +1000 (EST) Received: from localhost ([::1]:46304 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKS6G-0008Hq-Gl for incoming@patchwork.ozlabs.org; Fri, 13 Sep 2013 08:03:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKRul-0007Hg-RR for qemu-devel@nongnu.org; Fri, 13 Sep 2013 07:52:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKRuf-0001ZD-PP for qemu-devel@nongnu.org; Fri, 13 Sep 2013 07:51:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKRuf-0001Z1-Hv for qemu-devel@nongnu.org; Fri, 13 Sep 2013 07:51:49 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8DBpmc0005778 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 13 Sep 2013 07:51:48 -0400 Received: from dhcp-200-207.str.redhat.com (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r8DBp5F9032643; Fri, 13 Sep 2013 07:51:46 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 13 Sep 2013 13:51:02 +0200 Message-Id: <1379073063-14963-33-git-send-email-kwolf@redhat.com> In-Reply-To: <1379073063-14963-1-git-send-email-kwolf@redhat.com> References: <1379073063-14963-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PULL 32/33] 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 From: 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 Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- blockdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/blockdev.c b/blockdev.c index 2ab236a..80605a2 100644 --- a/blockdev.c +++ b/blockdev.c @@ -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;