Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5914945pxv; Thu, 29 Jul 2021 01:24:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNpuCMvMCrlTLs8BULM/qHxTWJujMr40lWNA5p04phbleTnVTCs/lGkFbYd39JAnHTDXeZ X-Received: by 2002:aa7:c603:: with SMTP id h3mr4602241edq.165.1627547060920; Thu, 29 Jul 2021 01:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627547060; cv=none; d=google.com; s=arc-20160816; b=0yfVeeYn8v5x0knCLTb4zKIbevrG3NQut16LVqudmQ5p5IoyrH84ls5zaKAPBdV7bk K//OASRBYCTwdMfh12R3LQgBcIyI9q/WehoFwQfGqD2Je8EVeXo290xKUyvpygVqR43D hdGHwhYgpixPFHzK9sEGCbu3nWQPha6BL8tRWG1ZZKh5h7NsOp+YQvA9ZOUD8en5bMsv XZt83C8wdNWQHsXm+S3Vaphag3+1DUo+OSxNVbkGPf0xpoRJw0CJREReroxb45MWeTkq B1BaXJKgE0yUoLii+LgOhoplHbqeXr6SajwTODdmboPYhhctGkGoRIPnUDANXlRUuKd3 nbcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=UsthJwMeSd4cOe5jnYdApLzz5rYNZWHrQmxAg4ixt6Q=; b=GFUT0Rop6TEhQGtFhy36AD+/RbaDP440lSCnDbUFcy9jyFFz2c72zz4XC4Jq4rlzR2 9gruWuBCLWEBRR5ksTlx48frVONWCYZ72733Mj0pAWSu0rWdoOP0bOvNEB3n9IDew6ep eQ7sgEO2KXCZuPu/24+v7wIZf+Y9lXm9P06oHwwlJO9IcWVYedAR+ypQnmTPhhQXyJCu NDOFYX5z4mOgvWIF3D4hoKo3XxeoDh6vpKk67AtKtkvQolCitnUkJBWvSrECdhuYsy7c t/HlFdye7gzgLNIS/DD5+qxhRXlS5zrbmXB+Ns+9FOU7FOappsX+yAwKrN5PYrUIfnmR tFGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ud4zSj5n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gf19si2241866ejb.430.2021.07.29.01.23.57; Thu, 29 Jul 2021 01:24:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ud4zSj5n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234880AbhG2IUk (ORCPT + 99 others); Thu, 29 Jul 2021 04:20:40 -0400 Received: from out0.migadu.com ([94.23.1.103]:38521 "EHLO out0.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234256AbhG2IUj (ORCPT ); Thu, 29 Jul 2021 04:20:39 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1627546835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=UsthJwMeSd4cOe5jnYdApLzz5rYNZWHrQmxAg4ixt6Q=; b=ud4zSj5nHpvOHFMmprz6tgWap+YmB6dBJTGT/jTfzKtHa4UrwvFgljQiWNqut9kdaSdFaB +ygnQDsVSch5bAW56IzLm71yyXvWysDISEQyCFcy9rwzFbcU6Ue12tyiqxSVbbDv1hkUep E9pyHMLpELVhNu+4VptgSiQoJtL1pgc= From: Yajun Deng To: pablo@netfilter.org, kadlec@netfilter.org, fw@strlen.de Cc: netfilter-devel@vger.kernel.org, coreteam@netfilter.org, bridge@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH v3] netfilter: nf_conntrack_bridge: Fix memory leak when error Date: Thu, 29 Jul 2021 16:20:21 +0800 Message-Id: <20210729082021.14407-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: yajun.deng@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It should be added kfree_skb_list() when err is not equal to zero in nf_br_ip_fragment(). v2: keep this aligned with IPv6. v3: modify iter.frag_list to iter.frag. Fixes: 3c171f496ef5 ("netfilter: bridge: add connection tracking system") Signed-off-by: Yajun Deng --- net/bridge/netfilter/nf_conntrack_bridge.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/bridge/netfilter/nf_conntrack_bridge.c b/net/bridge/netfilter/nf_conntrack_bridge.c index 8d033a75a766..d184306e1ba8 100644 --- a/net/bridge/netfilter/nf_conntrack_bridge.c +++ b/net/bridge/netfilter/nf_conntrack_bridge.c @@ -88,6 +88,11 @@ static int nf_br_ip_fragment(struct net *net, struct sock *sk, skb = ip_fraglist_next(&iter); } + + if (!err) + return 0; + + kfree_skb_list(iter.frag); return err; } slow_path: -- 2.32.0