From patchwork Wed Dec 12 17:58:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Pandit X-Patchwork-Id: 1012171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43FPkq1qZkz9s1c for ; Thu, 13 Dec 2018 05:01:22 +1100 (AEDT) Received: from localhost ([::1]:47026 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX8ow-00065B-Vn for incoming@patchwork.ozlabs.org; Wed, 12 Dec 2018 13:01:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gX8oJ-00062o-7N for qemu-devel@nongnu.org; Wed, 12 Dec 2018 13:00:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gX8oE-0005ro-OP for qemu-devel@nongnu.org; Wed, 12 Dec 2018 13:00:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49480) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gX8oE-0005qD-Go for qemu-devel@nongnu.org; Wed, 12 Dec 2018 13:00:34 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86AD32D7FF; Wed, 12 Dec 2018 18:00:32 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-138.sin2.redhat.com [10.67.116.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A09CB60C6A; Wed, 12 Dec 2018 18:00:29 +0000 (UTC) From: P J P To: Yuval Shaia Date: Wed, 12 Dec 2018 23:28:17 +0530 Message-Id: <20181212175817.815-1-ppandit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 12 Dec 2018 18:00:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] pvrdma: release device resources in case of an error 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: Li Qiang , Qemu Developers , Prasad J Pandit Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Prasad J Pandit If during pvrdma device initialisation an error occurs, pvrdma_realize() does not release memory resources, leading to memory leakage. Reported-by: Li Qiang Signed-off-by: Prasad J Pandit Reviewed-by: Yuval Shaia --- hw/rdma/vmw/pvrdma_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c index 8a03ab4669..b65f8662df 100644 --- a/hw/rdma/vmw/pvrdma_main.c +++ b/hw/rdma/vmw/pvrdma_main.c @@ -579,7 +579,7 @@ static void pvrdma_shutdown_notifier(Notifier *n, void *opaque) static void pvrdma_realize(PCIDevice *pdev, Error **errp) { - int rc; + int rc = 0; PVRDMADev *dev = PVRDMA_DEV(pdev); Object *memdev_root; bool ram_shared = false; @@ -655,6 +655,7 @@ static void pvrdma_realize(PCIDevice *pdev, Error **errp) out: if (rc) { + pvrdma_fini(pdev); error_append_hint(errp, "Device fail to load\n"); } }