From patchwork Fri Oct 11 14:00:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tonghao Zhang X-Patchwork-Id: 1175242 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="XNrlUpRl"; 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 46qVTx5WWjz9sP3 for ; Sat, 12 Oct 2019 01:20:21 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 244E81787; Fri, 11 Oct 2019 14:15:37 +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 2D85815B8 for ; Fri, 11 Oct 2019 14:06:08 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id AFAA5604 for ; Fri, 11 Oct 2019 14:06:06 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id q24so4511646plr.13 for ; Fri, 11 Oct 2019 07:06:06 -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:in-reply-to:references; bh=zlncg77ADu0xAcw2vtCSP/bdmGQFS+owGP7y9buZ2oo=; b=XNrlUpRldNYuMPajsX1IuRPts03eEc70J/gKHCs7BLn8fTVGI7qtbLpyDQqafwYXcB ADBvUOn3ZnDg5fJxwX3ftDeUMNUTc+kJiEmMd0FCuAe22ZTA8ScImx4eTBZVwj8PWgtY 0FRBL5X+GaxsoiN2zoV/6U3WULKJdhH5WTDIv6mCFg2PMvOgOVf+hLCELZeRFKjr5ZLs 5MlFQwYQsKNvEyB6NAtht2tLGvwCvG2sJ+0bppNwE6ncXSed0t731NW5spXQD6J3trhn DjcI3uZqTv/zyfl62kbsGtkamjUU0Q3hpjaADtXprKSS6j3csWVpZOIFUVwMK+jJ26GZ KYdg== 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=zlncg77ADu0xAcw2vtCSP/bdmGQFS+owGP7y9buZ2oo=; b=gUVx2TVrdO+OI0T616uZu90h/T/tVvL5lsmJEhw6Qh2cms1Q6tQFxXqOVyt76/UaVh kiYn2A17HHp37Y1EmGCnfofu1aaWGwpuesrDbx5BGQ5EiiwqN0sjlzqOxzOqUaA1rUtD tZFkCVTk4F1V1QMrPXCn0AjMKqj8KnVzbp9OnUDIXPpgOhZ+U1JSs3jYxq9gwY7p8i71 T/VA6AAwKAHOT58C9NEncIuTFuWzWRtQyVcbUhWGr9oVPqkpJT+OT1AdHehCHu33ToJR vw3/9CVxJvYdvc2OfiWaoMGxxPLGFZ39pNeEayFfBIGBJIykVHaejqYuXbfPn0RgpqMS LhSg== X-Gm-Message-State: APjAAAVCRGO4cGK+5rB6W4+oASbrS5gYBP1s1W3AxxiHmOyHYNqgjxPy cXKF+vVy05grSOzMx9/C/U4= X-Google-Smtp-Source: APXvYqxyCS4MO4gaF667vO/TXWgHomaVa0gQYRgh++EfEFtPjTNMZk73bdl44ZhY3R/oD842OapTCw== X-Received: by 2002:a17:902:8b83:: with SMTP id ay3mr15031786plb.269.1570802766522; Fri, 11 Oct 2019 07:06:06 -0700 (PDT) Received: from local.opencloud.tech.localdomain ([219.143.130.165]) by smtp.gmail.com with ESMTPSA id p190sm11499392pfb.160.2019.10.11.07.06.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Oct 2019 07:06:05 -0700 (PDT) From: xiangxia.m.yue@gmail.com To: gvrose8192@gmail.com, pshelar@ovn.org Date: Fri, 11 Oct 2019 22:00:45 +0800 Message-Id: <1570802447-8019-9-git-send-email-xiangxia.m.yue@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1570802447-8019-1-git-send-email-xiangxia.m.yue@gmail.com> References: <1570802447-8019-1-git-send-email-xiangxia.m.yue@gmail.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 Cc: dev@openvswitch.org, netdev@vger.kernel.org Subject: [ovs-dev] [PATCH net-next v3 08/10] net: openvswitch: fix possible memleak on destroy flow-table 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: Tonghao Zhang When we destroy the flow tables which may contain the flow_mask, so release the flow mask struct. Signed-off-by: Tonghao Zhang --- net/openvswitch/flow_table.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c index 1fc6be2..0317f1c 100644 --- a/net/openvswitch/flow_table.c +++ b/net/openvswitch/flow_table.c @@ -293,6 +293,18 @@ static void table_instance_destroy(struct table_instance *ti, } } +static void tbl_mask_array_destroy(struct flow_table *tbl) +{ + struct mask_array *ma = ovsl_dereference(tbl->mask_array); + int i; + + /* Free the flow-mask and kfree_rcu the NULL is allowed. */ + for (i = 0; i < ma->count; i++) + kfree_rcu(ma->masks[i], rcu); + + kfree_rcu(tbl->mask_array, rcu); +} + /* No need for locking this function is called from RCU callback or * error path. */ @@ -302,7 +314,7 @@ void ovs_flow_tbl_destroy(struct flow_table *table) struct table_instance *ufid_ti = rcu_dereference_raw(table->ufid_ti); free_percpu(table->mask_cache); - kfree_rcu(table->mask_array, rcu); + tbl_mask_array_destroy(table); table_instance_destroy(ti, ufid_ti, false); }