From patchwork Wed Mar 6 02:16:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 1052102 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=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="nfaQeIKv"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44DfLk08dnz9s9N for ; Wed, 6 Mar 2019 14:26:38 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id EC0DB9B01; Wed, 6 Mar 2019 03:23:21 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id DAA2ECBD for ; Wed, 6 Mar 2019 02:17:01 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 911A1180 for ; Wed, 6 Mar 2019 02:17:01 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id u9so7039168pgo.7 for ; Tue, 05 Mar 2019 18:17:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=QCdS1p5TU71eobUoKPlszjjaIZ4BLW4JlZrsS8S/mds=; b=nfaQeIKvqI0n69EXvrYPsELVpnjE+Rp4OHfXeIAb9BEwZzxQeYao/3WSJIc7akTk6A G+wZlx5s1IQvkYziVSmGKd1Fj4XrElcoYRBXmNxB9dgB8Gaj7jb3vOtflu0t6Ex8Sdor 9Lm9AKahDfa2N/v8X4yl4jk/Z+5SR0Qv9CZgX/VzFZzAYCqQRfCasnf8afrYFoPJV8mO KjF1rVh9oLLwiT1lrbjc1LSDl8Pn8EhJpkKuh9uaLhhR/xx3FNNU5d3uzLNUR0d2fFNc JJtu7s1/cCUov31rlcJRmjN7ci5Lp6kUnr6SNpAp1op3rxbu2H1RxIdefcJP8uUz7PiN uyRA== 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=QCdS1p5TU71eobUoKPlszjjaIZ4BLW4JlZrsS8S/mds=; b=p0ZHsBGhT+DCg6zhasEpIdJBQe72VkOOe5vfP5E7wyPcPVHXGgMeu+/O3o4fduNUD7 G81/osP9zKpt7PjAHGz1RAtvUhyr02xNpCmW+R6vkmvlpLPvfJ50k3W6JLOTd7tl4ig7 KRlUXcWppZ3rUCsn74Msepqpcq/au7EMbqVGndT4//YQxWiGTQb+gwWD0NCHeT3z5KgA UUXKpzrVFW8OLohQOt3LGhEhvhDguTosluhc4tlp9WAgp1f/Y80BGWBV50HRr/2NsNxV D+7tSXWaAwVw5CbSqzwIeR6cPst0goPF5L0+Dti1vcDorXn8vOEs3PGARLsSCZND2ZSZ u6Iw== X-Gm-Message-State: APjAAAVDt5hsrleLuP19yVqN5cRqFi+uxHFb28L0+xnaz9gDg6Iy9nMA NPTkdtEjf9VjhtwOqS0pnrzQtLoJ X-Google-Smtp-Source: APXvYqzphd9ERjyAPQO4mETt0eGTYVHxLqxYyUOe5tPfyVyzpAkkiwjjLGB2REGCK/+zI0buvX2zxA== X-Received: by 2002:a17:902:1e6:: with SMTP id b93mr4339485plb.325.1551838620602; Tue, 05 Mar 2019 18:17:00 -0800 (PST) Received: from localhost.localdomain.localdomain ([216.113.160.77]) by smtp.gmail.com with ESMTPSA id z189sm454291pfb.146.2019.03.05.18.16.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 18:17:00 -0800 (PST) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Tue, 5 Mar 2019 18:16:49 -0800 Message-Id: <1551838610-66580-1-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 1/2] ovsdb-idl: Fix memory leak of ovsdb_idl_delete_row. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Han Zhou When a row is deleted, if it is referenced by another row, the function ovsdb_idl_row_reparse_backrefs() is called but in that function it doesn't destroy the row, because parameter destroy_dsts is false when ovsdb_idl_row_reparse_backrefs() calls ovsdb_idl_row_clear_arcs(). Signed-off-by: Han Zhou --- lib/ovsdb-idl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index 8cfb201..49fd45c 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -3208,6 +3208,7 @@ ovsdb_idl_delete_row(struct ovsdb_idl_row *row) ovsdb_idl_row_destroy(row); } else { ovsdb_idl_row_reparse_backrefs(row); + ovsdb_idl_row_destroy(row); } } From patchwork Wed Mar 6 02:16:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 1052103 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=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VcgLiQir"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44DfMC41NSz9sDn for ; Wed, 6 Mar 2019 14:27:03 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AD12C9AFF; Wed, 6 Mar 2019 03:23:22 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id D59A4CBD for ; Wed, 6 Mar 2019 02:17:02 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 9563C180 for ; Wed, 6 Mar 2019 02:17:02 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id 196so7038066pgf.13 for ; Tue, 05 Mar 2019 18:17:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=db8X4Did3fHm7t4B+2uwLjWvA0St5pDKd7feyIW9JLY=; b=VcgLiQirUXOs5nfhaySbYDrLvjaAlGW+Z4vS5Xi0kYngw203To3LtGYDtQcC91Odc5 TsmHqn2J3Dx3XmqxQIvSJX6q3OjN7lYwjzYHn31e+nLeqsAE3f7+RbtuMdN6s6p6DPJa yJNVO+71+cLLHHwJXnBZrRL6pp8qliAUhrqU5XMQoGUP+wJ9N2SYByg8S9F88eGkIOUQ WH5abeUKaY2QrKbBlQfJADw5WTvztpW3d0FlJ93kb6xm91ELIMHKDRFDbScg+OhnIIR3 145BAAVgjLkLvTHFro3SIMAXLpoM3fwtgW96jlSq0ZA9Ih16IYumSZTon8OE0P0RCA9O 3umg== 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:in-reply-to :references; bh=db8X4Did3fHm7t4B+2uwLjWvA0St5pDKd7feyIW9JLY=; b=Qvw2GoJzXvvlEHlYPRvopJoQAA2sqGMzYArGl7L4yq2TtgR/TciLpES02nt8te5VYq uQCHQZOFbGXNbM92+Uj9IcKD1AktwMCtxcTyO6FgigKVT+vXbm6YdpfN0thYgfhlWTbu VSfJ0CnbY1iEt1965MJQCk38HDJmhkeijDHHP+7ZNF2Gx7E2hEz54qRufv9PPVAB+dbN TnY/PO6/VFQ1RxQGL7pd5b6TPqm0nIpnp4pKos8Y1X4EYM19GZQ5IETfug1B0WaB2dqX Q/60GSUxn8InM/fDhzE2NfdvCwQuxylNV7kspoF1Zy4xMFu2OzZHu5vPrueivE01rXFr E1mg== X-Gm-Message-State: APjAAAU06smzQ5bg6498SK0YVZaA2k8Rmba7NB/Ht5d7I653uhGdgUJY nCZohDF8wXwfiSyyoDK0OZ91y2C6 X-Google-Smtp-Source: APXvYqx5/JFwivrRIiJ237CLL1XLwKpmqrcp3pQ63zwYzQmlHlTOnHBa6axTUyyE+9o5pm3KnroesA== X-Received: by 2002:a17:902:854b:: with SMTP id d11mr4288929plo.224.1551838621418; Tue, 05 Mar 2019 18:17:01 -0800 (PST) Received: from localhost.localdomain.localdomain ([216.113.160.77]) by smtp.gmail.com with ESMTPSA id z189sm454291pfb.146.2019.03.05.18.17.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Mar 2019 18:17:00 -0800 (PST) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Tue, 5 Mar 2019 18:16:50 -0800 Message-Id: <1551838610-66580-2-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1551838610-66580-1-git-send-email-hzhou8@ebay.com> References: <1551838610-66580-1-git-send-email-hzhou8@ebay.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 2/2] ovsdb-idl: Fix memory leak of ovsdb_idl_db_clear. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Han Zhou ovsdb_idl_row_destroy() doesn't free the memory of row structure itself. This is because of the ovsdb change tracking feature: the deleted row may be accessed in the current iteration of main loop. The function ovsdb_idl_row_destroy_postprocess() is called at the end of ovsdb_idl_run() to free the deleted rows that are not tracked; the function ovsdb_idl_db_track_clear() is called (indirectly) by user at the end of each main loop iteration to free the deleted rows that are tracked. However, in ovsdb_idl_db_clear(), which may be called when a session is reset, or when the idl is destroyed, it didn't call ovsdb_idl_row_destroy_postprocess(), which would result in all the untracked rows leaked. This patch fixes that. Signed-off-by: Han Zhou --- lib/ovsdb-idl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index 49fd45c..2af123b 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -616,6 +616,7 @@ ovsdb_idl_db_clear(struct ovsdb_idl_db *db) ovsdb_idl_row_destroy(row); } } + ovsdb_idl_row_destroy_postprocess(db); db->cond_changed = false; db->cond_seqno = 0;