Message ID | 20180723201748.25573-98-mdroth@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org> 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 8EDD791E for <patchwork-qemu-devel@patchwork.kernel.org>; Mon, 23 Jul 2018 21:46:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E41A285C9 for <patchwork-qemu-devel@patchwork.kernel.org>; Mon, 23 Jul 2018 21:46:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71C60285CC; Mon, 23 Jul 2018 21:46:58 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 08F82285C9 for <patchwork-qemu-devel@patchwork.kernel.org>; Mon, 23 Jul 2018 21:46:58 +0000 (UTC) Received: from localhost ([::1]:36931 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org>) id 1fhifR-0007gQ-8H for patchwork-qemu-devel@patchwork.kernel.org; Mon, 23 Jul 2018 17:46:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <flukshun@gmail.com>) id 1fhhLR-0004d5-Nd for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <flukshun@gmail.com>) id 1fhhLQ-0005lr-PC for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:22:13 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:46074) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from <flukshun@gmail.com>) id 1fhhLQ-0005lZ-IQ; Mon, 23 Jul 2018 16:22:12 -0400 Received: by mail-oi0-x244.google.com with SMTP id q11-v6so3459448oic.12; Mon, 23 Jul 2018 13:22:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=RWOr/A6TE00pGF7W4hXfH4qpPjRI8MD+OTC4K1r7Y/I=; b=CIC9jDb7LgPXqcKP4Kkj1gvz5imBsa6lBDCfMFG3gwrHBflavORO9ja58MI6Yb8GAQ H+UnOmoUUbzjidpyp1piZPj+EftO1KAo8zisq0Zj+60ceFWBrF1yj939z4Jhvl2RqkwL PzO2fRxesxl02mNtUjcD4I+I/yDipEOE11CZn2hr6hea+vNbyw88Hc5YChhI/yZge9HU pWlvAtVic/sLc1XdN2XEMKPJbWJZ3UsEMfctiAzDDb7uECGr7q3LKvBnrIYuGwZTwtdo m/IUVwg1HAWk3joVpLcazaRKkY2ZRq8Rv3oIVzBKaHEpendiwWS+IqENjq6nLonfmC70 rldQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=RWOr/A6TE00pGF7W4hXfH4qpPjRI8MD+OTC4K1r7Y/I=; b=BAvyq78o7ohCgONniGkD284tI+4zZsaYD3mVnuwqPDU5LIR/lXW6/uhAPmHRPtGAyW SLyR/8ZEF9ng/Ibvs+hWJKnLWEHu9b9gbb6LJze1RjE2afm9tJNrnzWc6NlRunXR1gC2 vGapnsdupgrLCdL7jIoHxrIZkg8j9Bl35Zw0Wl4jvKi7ABwEiCzIC3szoITQpmCAFhjs uoFe/51MY+TqdnFqBnv390UOE02kIrXo/Mr25+YgvT2LaFBHgO1/JSGc33wN6/mobbee 4aYLxdvEngVu9q8NlMBOlhSEjRhq30WDLZZij5o6Zbjl66pLXFRD9vadcDqSypP2VSP2 amYA== X-Gm-Message-State: AOUpUlFm3PhAtuPZB3K2J06L4d2et5wdTP9VoFVeJ3X1nAQ0PK+PEbhJ gNSuiG3D6Zq5xrRyqrWICumm0slWucD3PA== X-Google-Smtp-Source: AAOMgpc+zxC7MkgaBntnkjV6edJvFb5xY2zo9UQ3IaWxm+oYXPzY2hOdEGE8RAHvrcph+YJjLYklcg== X-Received: by 2002:aca:d0d7:: with SMTP id j84-v6mr264556oiy.189.1532377331455; Mon, 23 Jul 2018 13:22:11 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id m203-v6sm25503729oig.42.2018.07.23.13.22.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:22:10 -0700 (PDT) From: Michael Roth <mdroth@linux.vnet.ibm.com> To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:46 -0500 Message-Id: <20180723201748.25573-98-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH 97/99] tap: fix memory leak on success to create a tap device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: <qemu-devel.nongnu.org> List-Unsubscribe: <https://lists.nongnu.org/mailman/options/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe> List-Archive: <http://lists.nongnu.org/archive/html/qemu-devel/> List-Post: <mailto:qemu-devel@nongnu.org> List-Help: <mailto:qemu-devel-request@nongnu.org?subject=help> List-Subscribe: <https://lists.nongnu.org/mailman/listinfo/qemu-devel>, <mailto:qemu-devel-request@nongnu.org?subject=subscribe> Cc: Jason Wang <jasowang@redhat.com>, Yunjian Wang <wangyunjian@huawei.com>, qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" <qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org> X-Virus-Scanned: ClamAV using ClamSMTP |
Series |
Patch Round-up for stable 2.12.1, freeze on 2018-07-30
|
expand
|
diff --git a/net/tap.c b/net/tap.c index 89c4e19162..e807e0ea2f 100644 --- a/net/tap.c +++ b/net/tap.c @@ -805,7 +805,8 @@ int net_init_tap(const Netdev *netdev, const char *name, } else if (tap->has_fds) { char **fds; char **vhost_fds; - int nfds, nvhosts; + int nfds = 0, nvhosts = 0; + int ret = 0; if (tap->has_ifname || tap->has_script || tap->has_downscript || tap->has_vnet_hdr || tap->has_helper || tap->has_queues || @@ -825,6 +826,7 @@ int net_init_tap(const Netdev *netdev, const char *name, if (nfds != nvhosts) { error_setg(errp, "The number of fds passed does not match " "the number of vhostfds passed"); + ret = -1; goto free_fail; } } @@ -833,6 +835,7 @@ int net_init_tap(const Netdev *netdev, const char *name, fd = monitor_fd_param(cur_mon, fds[i], &err); if (fd == -1) { error_propagate(errp, err); + ret = -1; goto free_fail; } @@ -843,6 +846,7 @@ int net_init_tap(const Netdev *netdev, const char *name, } else if (vnet_hdr != tap_probe_vnet_hdr(fd)) { error_setg(errp, "vnet_hdr not consistent across given tap fds"); + ret = -1; goto free_fail; } @@ -852,21 +856,21 @@ int net_init_tap(const Netdev *netdev, const char *name, vnet_hdr, fd, &err); if (err) { error_propagate(errp, err); + ret = -1; goto free_fail; } } - g_free(fds); - g_free(vhost_fds); - return 0; free_fail: + for (i = 0; i < nvhosts; i++) { + g_free(vhost_fds[i]); + } for (i = 0; i < nfds; i++) { g_free(fds[i]); - g_free(vhost_fds[i]); } g_free(fds); g_free(vhost_fds); - return -1; + return ret; } else if (tap->has_helper) { if (tap->has_ifname || tap->has_script || tap->has_downscript || tap->has_vnet_hdr || tap->has_queues || tap->has_vhostfds) {