From patchwork Tue Jan 31 09:33:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yotam Gigi X-Patchwork-Id: 721878 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vCLdV2yQwz9ryZ for ; Tue, 31 Jan 2017 20:32:30 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751379AbdAaJcT (ORCPT ); Tue, 31 Jan 2017 04:32:19 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:46503 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751206AbdAaJcH (ORCPT ); Tue, 31 Jan 2017 04:32:07 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yotamg@mellanox.com) with ESMTPS (AES256-SHA encrypted); 31 Jan 2017 11:31:29 +0200 Received: from dev-r-vrt-156.mtr.labs.mlnx (dev-r-vrt-156.mtr.labs.mlnx [10.212.156.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v0V9VSue028212; Tue, 31 Jan 2017 11:31:29 +0200 From: Yotam Gigi To: davem@davemloft.net, jhs@mojatatu.com, netdev@vger.kernel.org, jiri@mellanox.com, eladr@mellanox.com Cc: Yotam Gigi Subject: [PATCH net-next 1/2] net/sched: act_sample: Fix error path in init Date: Tue, 31 Jan 2017 11:33:53 +0200 Message-Id: <1485855234-9941-2-git-send-email-yotamg@mellanox.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1485855234-9941-1-git-send-email-yotamg@mellanox.com> References: <1485855234-9941-1-git-send-email-yotamg@mellanox.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Fix error path of in sample init, by releasing the tc hash in case of failure in psample_group creation. Fixes: 5c5670fae430 ("net/sched: Introduce sample tc action") Reported-by: Cong Wang Reviewed-by: Jiri Pirko Signed-off-by: Yotam Gigi --- net/sched/act_sample.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index 3922975..02b6749 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -81,8 +81,11 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, s->rate = nla_get_u32(tb[TCA_SAMPLE_RATE]); s->psample_group_num = nla_get_u32(tb[TCA_SAMPLE_PSAMPLE_GROUP]); psample_group = psample_group_get(net, s->psample_group_num); - if (!psample_group) + if (!psample_group) { + if (ret == ACT_P_CREATED) + tcf_hash_release(*a, bind); return -ENOMEM; + } RCU_INIT_POINTER(s->psample_group, psample_group); if (tb[TCA_SAMPLE_TRUNC_SIZE]) {