From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4721BC5AD49 for ; Tue, 27 May 2025 23:30:00 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uK3jI-0005aJ-Lp; Tue, 27 May 2025 19:29:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uK3jH-0005aB-La for qemu-devel@nongnu.org; Tue, 27 May 2025 19:29:07 -0400 Received: from ssh.movementarian.org ([139.162.205.133] helo=movementarian.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uK3jG-0002uF-Dq for qemu-devel@nongnu.org; Tue, 27 May 2025 19:29:07 -0400 Received: from movement by movementarian.org with local (Exim 4.97) (envelope-from ) id 1uK3jC-0000000CFpy-13sy; Wed, 28 May 2025 00:29:02 +0100 Date: Wed, 28 May 2025 00:29:02 +0100 From: John Levon To: Steve Sistare Cc: qemu-devel@nongnu.org, Cedric Le Goater , Alex Williamson Subject: Re: [PATCH] vfio/pci: vfio_pci_put_device on failure Message-ID: References: <1748379412-150475-1-git-send-email-steven.sistare@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1748379412-150475-1-git-send-email-steven.sistare@oracle.com> X-Url: http://www.movementarian.org/ Received-SPF: pass client-ip=139.162.205.133; envelope-from=movement@movementarian.org; helo=movementarian.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Tue, May 27, 2025 at 01:56:52PM -0700, Steve Sistare wrote: > If vfio_realize fails after vfio_device_attach, it should call > vfio_device_detach during error recovery. If it fails after > vfio_device_get_name, it should free vbasedev->name. If it fails > after vfio_pci_config_setup, it should free vdev->msix. > > To fix all, call vfio_pci_put_device(). > > Signed-off-by: Steve Sistare > --- > hw/vfio/pci.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c > index a1bfdfe..7d3b9ff 100644 > --- a/hw/vfio/pci.c > +++ b/hw/vfio/pci.c > @@ -3296,6 +3296,7 @@ out_teardown: > vfio_bars_exit(vdev); > error: > error_prepend(errp, VFIO_MSG_PREFIX, vbasedev->name); > + vfio_pci_put_device(vdev); > } > > static void vfio_instance_finalize(Object *obj) Reviewed-by: John Levon