From patchwork Tue Oct 6 23:16:00 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 35166 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A5CB9B7BC2 for ; Wed, 7 Oct 2009 10:16:47 +1100 (EST) Received: from localhost ([127.0.0.1]:37161 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvJGt-0003MZ-Hw for incoming@patchwork.ozlabs.org; Tue, 06 Oct 2009 19:16:43 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MvJGL-0003Lh-Mg for qemu-devel@nongnu.org; Tue, 06 Oct 2009 19:16:09 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MvJGH-0003KM-91 for qemu-devel@nongnu.org; Tue, 06 Oct 2009 19:16:09 -0400 Received: from [199.232.76.173] (port=52555 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvJGG-0003KI-T6 for qemu-devel@nongnu.org; Tue, 06 Oct 2009 19:16:04 -0400 Received: from oxygen.pond.sub.org ([213.239.205.148]:50050) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MvJGG-0005Hg-G7 for qemu-devel@nongnu.org; Tue, 06 Oct 2009 19:16:04 -0400 Received: from pike.pond.sub.org (pD9E3BD77.dip.t-dialin.net [217.227.189.119]) by oxygen.pond.sub.org (Postfix) with ESMTPA id D84A02DAA28 for ; Wed, 7 Oct 2009 01:16:02 +0200 (CEST) Received: by pike.pond.sub.org (Postfix, from userid 1000) id 46DDA1009E; Wed, 7 Oct 2009 01:16:01 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 7 Oct 2009 01:16:00 +0200 Message-Id: X-Mailer: git-send-email 1.6.0.6 In-Reply-To: References: X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [Qemu-devel] [PATCH 6/7] Warn if value of qdev_init() isn't checked X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org After qdev_init() fails, the device is gone. Failure to check runs a high risk of use-after-free. Signed-off-by: Markus Armbruster --- hw/qdev.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/qdev.h b/hw/qdev.h index b385b25..8cd843e 100644 --- a/hw/qdev.h +++ b/hw/qdev.h @@ -100,7 +100,7 @@ struct CompatProperty { DeviceState *qdev_create(BusState *bus, const char *name); DeviceState *qdev_device_add(QemuOpts *opts); -int qdev_init(DeviceState *dev); +int qdev_init(DeviceState *dev) __attribute__((warn_unused_result)); void qdev_init_nofail(DeviceState *dev); int qdev_unplug(DeviceState *dev); void qdev_free(DeviceState *dev);