From: Markus Armbruster Subject: Re: [PATCH] Avoid segmentation fault for qdev device not found Date: Fri, 13 May 2011 10:41:47 +0200 Message-ID: References: <1305204903-13283-1-git-send-email-glommer@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: aliguori@us.ibm.com, mtosatti@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, avi@redhat.com To: Glauber Costa Return-path: In-Reply-To: <1305204903-13283-1-git-send-email-glommer@redhat.com> (Glauber Costa's message of "Thu, 12 May 2011 09:55:03 -0300") List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org Glauber Costa writes: > qdev_try_create will cope well with a NULL bus, since it will assume > the main system bus by default. qdev_create, however, wants to print > a message, in which it instantiates the bus name. That simple and at > first inoffensive message will generate a segmentation found if the > reason for failure is a NULL bus. > > I propose we avoid that - thus generating the normal hw_error by > always passing a valid bus to qdev_try_create - if none, be it the > main system bus. > > The code for testing a NULL bus is not remove from qdev_try_create > because it is a externally visible function, and we want it to continue > working fine. > > Signed-off-by: Glauber Costa "NULL means implicit main system bus" is too clever. See also commit ec990eb6. Beyond the scope of your simple fix, so: Reviewed-by: Markus Armbruster