From patchwork Wed Apr 13 10:08:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 8820361 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BEAECC0553 for ; Wed, 13 Apr 2016 10:08:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 183DE2034C for ; Wed, 13 Apr 2016 10:08:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E24BD2034F for ; Wed, 13 Apr 2016 10:08:30 +0000 (UTC) Received: from localhost ([::1]:40543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqHio-0001E4-8h for patchwork-qemu-devel@patchwork.kernel.org; Wed, 13 Apr 2016 06:08:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqHiY-00016a-Bu for qemu-devel@nongnu.org; Wed, 13 Apr 2016 06:08:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aqHiW-0008Qd-VA for qemu-devel@nongnu.org; Wed, 13 Apr 2016 06:08:14 -0400 Received: from mail-qg0-x231.google.com ([2607:f8b0:400d:c04::231]:33822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqHiW-0008QX-Rc for qemu-devel@nongnu.org; Wed, 13 Apr 2016 06:08:12 -0400 Received: by mail-qg0-x231.google.com with SMTP id c6so38906363qga.1 for ; Wed, 13 Apr 2016 03:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7gClbZ7MfSnc6c0hcHGMr4+ApDZRHkyra53nUoIe8Jg=; b=oty9L7Txy+T33uIuDrSlMsO4sn0+vcxf/HHFJ5PKWm3fNAR4uPPgJGH9HUP7KFEWB1 UXYjUvRvUD8wXKSoywcDtqlFPvFHdeE3VRwb9LFn88EMS73sRCCWyg8YpNORjofi+qv0 64Vt+PO4MPU7BPOYO0gRkwHvjYNppjVEojSEjDASDK1kDDV+n17nQu2UvsDjttQVidNg iu7bDhHM8Jmjfs6gZA+oT2x2GRYPf0sW9kHznI1t2fFa9rr2X6kD7Fns5mpa5hNFDwZ5 84FIAAhV5R/vimslBMb4CbBCmSO5gqf9NMZTD9Nw0+tJ4p29ZG+j0VE1KGEvvn+JH/4n K+zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=7gClbZ7MfSnc6c0hcHGMr4+ApDZRHkyra53nUoIe8Jg=; b=V1EtKWnd7wR2YKuZPZOyM6zaLr6FY4LT349tLQCfGruMPzjPWjMC5VEanJZIkw7OPo 0YdMJl8LpRDV1tfVS8SfLbLxsnoYvRMdadRAe99ZID37sQ5ze5duH5lmvSb1ihbtWaue 7Mhm8T3MuskLhfbQR4Q9dJuNoKHxGR/k/rgr35ihAQ2KONU9H/GT2l+Ux43MNYyJE3VD WKBw7LVqvldE6KQYrTTjVv7zk+d5RS/HbminDOjbKHGOBiKoNu/FRgLt+GwWkSfBNHQO fYqShWy0WFO3UTLc/hetqjA8ohoLEjwfJ9sWxk7Vh++kWJjQL6tzvR+kVMP68JAk7N6y Lo7A== X-Gm-Message-State: AOPr4FVbGZ/Aq16ij2cBzop4l4q7fbytFSsngmg9U2NFDm1uU1AmtHskoqytmb5ySJC9DA== X-Received: by 10.140.106.11 with SMTP id d11mr9824063qgf.80.1460542092586; Wed, 13 Apr 2016 03:08:12 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by smtp.gmail.com with ESMTPSA id 65sm15494235qgz.40.2016.04.13.03.08.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Apr 2016 03:08:11 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Wed, 13 Apr 2016 12:08:04 +0200 Message-Id: <1460542084-31446-2-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1460542084-31446-1-git-send-email-marcandre.lureau@redhat.com> References: <1460542084-31446-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c04::231 Subject: [Qemu-devel] [PULL 1/1] ivshmem: fix ivshmem-{plain, doorbell} crash without arg X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc-André Lureau "qemu -device ivshmem-{plain,doorbell}" will crash, because the device doesn't check that the required argument is provided. (screwed up in commit 5400c02) Signed-off-by: Marc-André Lureau Reviewed-by: Markus Armbruster --- hw/misc/ivshmem.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 2eb8668..e40f23b 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -872,6 +872,8 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp) s->ivshmem_bar2 = host_memory_backend_get_memory(s->hostmem, &error_abort); } else { + assert(s->server_chr); + IVSHMEM_DPRINTF("using shared memory server (socket = %s)\n", s->server_chr->filename); @@ -1051,10 +1053,24 @@ static void ivshmem_plain_init(Object *obj) &error_abort); } +static void ivshmem_plain_realize(PCIDevice *dev, Error **errp) +{ + IVShmemState *s = IVSHMEM_COMMON(dev); + + if (!s->hostmem) { + error_setg(errp, "You must specify a 'memdev'"); + return; + } + + ivshmem_common_realize(dev, errp); +} + static void ivshmem_plain_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + k->realize = ivshmem_plain_realize; dc->props = ivshmem_plain_properties; dc->vmsd = &ivshmem_plain_vmsd; } @@ -1099,10 +1115,24 @@ static void ivshmem_doorbell_init(Object *obj) s->legacy_size = SIZE_MAX; /* whatever the server sends */ } +static void ivshmem_doorbell_realize(PCIDevice *dev, Error **errp) +{ + IVShmemState *s = IVSHMEM_COMMON(dev); + + if (!s->server_chr) { + error_setg(errp, "You must specify a 'chardev'"); + return; + } + + ivshmem_common_realize(dev, errp); +} + static void ivshmem_doorbell_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + k->realize = ivshmem_doorbell_realize; dc->props = ivshmem_doorbell_properties; dc->vmsd = &ivshmem_doorbell_vmsd; }