From patchwork Mon Jul 15 10:23:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 11043551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DC2176C5 for ; Mon, 15 Jul 2019 10:24:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB6331FF7F for ; Mon, 15 Jul 2019 10:24:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD7A928399; Mon, 15 Jul 2019 10:24:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 90B671FF7F for ; Mon, 15 Jul 2019 10:24:02 +0000 (UTC) Received: from localhost ([::1]:36666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmy9J-0000sz-G1 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 15 Jul 2019 06:24:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35026) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hmy98-0000Ig-D7 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 06:23:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hmy97-00081p-H5 for qemu-devel@nongnu.org; Mon, 15 Jul 2019 06:23:50 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:42416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hmy97-00080i-BB for qemu-devel@nongnu.org; Mon, 15 Jul 2019 06:23:49 -0400 Received: by mail-pl1-x641.google.com with SMTP id ay6so8064928plb.9 for ; Mon, 15 Jul 2019 03:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=7p2G/91PqJ8RuOo5lhHUra5YVPwP+D+LVK4urSQ4OpA=; b=bK8x2Zr8/rJFONtuAaOfrtOkNr+LN0fAHst74lyaoE/b4xJoshc32toRLNjbp7t4b+ fR53E6LnIEU91KEH/9bNUCIUCkFeIBLGNtI/5PlrzRNqns85E9HDpzd0D/GKUzqkRS3C /2LRkWsDx9ZeZcbSGssQm7/2Jg/1xvs37r5qx9m/83+bzVu7N5aAZxf3Ma1CBaVpAYot PsKkszco34qXXLlMQphUIJG0hyHboF50ZAFjCHYidCTUkd9rUE7KVaeX6V/KJ/f82Wjv 3H03CVi2ZZZiWBhcztYJIDxUZIXirtXUfLxUKLfqZVxWscHLZYzXLsBkVP7X7QnILPuH ooUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7p2G/91PqJ8RuOo5lhHUra5YVPwP+D+LVK4urSQ4OpA=; b=SCHnylV0bVnPnfc9VOvEO/PlyKyj2T3/DaGc4iWQaw31nybpDJO9ZFWDTAKhpcC5au 4+PrlJxnOGGrZjqOJafMRk0NG5MPYoWmkKIvvw40f4FynnFNfeiVke7ZdvVyQpnEZwbG 0Qcr7SMvOd0rhPJzApk6s1om+mMG01nDRv8jIKkIai+rWHvSim1VblOaJfwxyL1udcHO RpzqgZNN9rrPPZjJyOZJkjdktpz7HxFHPjSWTSDDSMVW4nifwlW9JSeQGi+JDXZuDsu0 O0ZvMTVc+27+CnflDHLUPhWuhMx4r6lbzIj0xRpkTWec3bWdmq/t3aow/ONn9hLQOHNE ny7w== X-Gm-Message-State: APjAAAWrJo0Pcw44sMNWujN6rSqtVWmXcoM5/tW0RlV0r3WgFfXnLmN/ GD0eW5QkKj6qITHS5i+u/T0= X-Google-Smtp-Source: APXvYqw9SB3SBYrMcDya6hs0EDVcdlmoLhSkZ6Jbt01rgAl+Zm4S0dJYhRxYG4WEYGb3zPHVuB2VHg== X-Received: by 2002:a17:902:6b85:: with SMTP id p5mr25069625plk.225.1563186227723; Mon, 15 Jul 2019 03:23:47 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id m9sm31381908pgr.24.2019.07.15.03.23.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Jul 2019 03:23:47 -0700 (PDT) From: elohimes@gmail.com X-Google-Original-From: xieyongji@baidu.com To: mst@redhat.com, stefanha@gmail.com, pbonzini@redhat.com, fam@euphon.net Date: Mon, 15 Jul 2019 18:23:25 +0800 Message-Id: <20190715102326.2805-1-xieyongji@baidu.com> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH 1/2] vhost-scsi: Call virtio_scsi_common_unrealize() when device realize failed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xie Yongji , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Xie Yongji This avoids memory leak when device hotplug is failed. Signed-off-by: Xie Yongji --- hw/scsi/vhost-scsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 4090f99ee4..db4a090576 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -210,7 +210,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) if (err) { error_propagate(errp, err); error_free(vsc->migration_blocker); - goto close_fd; + goto free_virtio; } } @@ -240,6 +240,8 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp) migrate_del_blocker(vsc->migration_blocker); } g_free(vsc->dev.vqs); + free_virtio: + virtio_scsi_common_unrealize(dev, errp); close_fd: close(vhostfd); return;