From patchwork Thu Apr 6 11:19:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Feng X-Patchwork-Id: 747704 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vzKxL57Pfz9s8N for ; Thu, 6 Apr 2017 21:19:50 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=foxmail.com header.i=@foxmail.com header.b="OplCOtRl"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932811AbdDFLTt (ORCPT ); Thu, 6 Apr 2017 07:19:49 -0400 Received: from smtpproxy19.qq.com ([184.105.206.84]:38176 "EHLO smtpproxy19.qq.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753899AbdDFLTt (ORCPT ); Thu, 6 Apr 2017 07:19:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1491477586; bh=EHZqPYU3qQkyoNHfDw02rYVblKITWkfTKrAf6BwzJbI=; h=From:To:Cc:Subject:Date:Message-Id; b=OplCOtRlkfp3NYLzoATD3SenlaJ8RTlHqS8lFpmV3Gi5/9QCjWcNCimIMgVeuKyAK dd8yLd32K/U01RE+5fofn39ZhKT1/AvKx4SCSDSLjnhXML/q40k96cBBl1A/0XzKJ8 pvUxG+B2mehAEPpL7OksX5QpI0nsihazNDVcDTaE= X-QQ-mid: esmtp31t1491477584tnjbq7b2z Received: from ikuai8.com (unknown [114.242.17.234]) by esmtp4.qq.com (ESMTP) with id ; Thu, 06 Apr 2017 19:19:35 +0800 (CST) X-QQ-SSF: 01000000000000F0FF400F00000000Q X-QQ-FEAT: jLTfbrzLdoMyLFvCzAo4OQE+72PsYAkaKSKSItJ1fKDKV8TRzE/vOdANivPlR OVlZCe1qRU1cgywnl+2LfM4HA0uNaWRRfO0+INEOxION+Kq1M1G4eQmZQfYVkZvLlVTqed6 ey1ARADclA78DTK/4ECWljLBJeyXVp7r8i2Zih3tLeRaWN7HPDOMwW8HtQVnzKgnBqVqpQ2 HWS2xRr29eSKHLqJo4xheihIzAn0fbkFAa+L4KYPmqApbpQyh/sO9yjyjSQJf2WJGDYiW+t 6JEVBaDIofDug86lrGIPOD2go= X-QQ-GoodBg: 0 From: gfree.wind@foxmail.com To: pablo@netfilter.org, netfilter-devel@vger.kernel.org Cc: Gao Feng Subject: [PATCH nf v2 1/1] netfilter: xt_CT: Fix one possible memleak of timeout Date: Thu, 6 Apr 2017 19:19:34 +0800 Message-Id: <1491477574-82700-1-git-send-email-gfree.wind@foxmail.com> X-Mailer: git-send-email 1.9.1 X-QQ-SENDSIZE: 520 Feedback-ID: esmtp:foxmail.com:bgforeign:bgforeign1 X-QQ-Bgrelay: 1 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org From: Gao Feng When nf_ct_timeout_ext_add failed in xt_ct_set_timeout, it should free the timeout refcnt. Now goto the err_put_timeout error handler instead of going ahead. Signed-off-by: Gao Feng --- v2: Keep the ret = -ENOMEM, per Gao Feng v1: initial version net/netfilter/xt_CT.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/netfilter/xt_CT.c b/net/netfilter/xt_CT.c index b008db0..a1783b6 100644 --- a/net/netfilter/xt_CT.c +++ b/net/netfilter/xt_CT.c @@ -167,8 +167,10 @@ static void __xt_ct_tg_timeout_put(struct ctnl_timeout *timeout) goto err_put_timeout; } timeout_ext = nf_ct_timeout_ext_add(ct, timeout, GFP_ATOMIC); - if (timeout_ext == NULL) + if (!timeout_ext) { ret = -ENOMEM; + goto err_put_timeout; + } rcu_read_unlock(); return ret;