소스 검색

netfilter: nfnetlink_queue: fix memory leak when attach expectation successfully

User can use NFQA_EXP to attach expectations to conntracks, but we
forget to put back nf_conntrack_expect when it is inserted successfully,
i.e. in this normal case, expect's use refcnt will be 3. So even we
unlink it and put it back later, the use refcnt is still 1, then the
memory will be leaked forever.

Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Liping Zhang 9 년 전
부모
커밋
b18bcb0019
1개의 변경된 파일2개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 6
      net/netfilter/nf_conntrack_netlink.c

+ 2 - 6
net/netfilter/nf_conntrack_netlink.c

@@ -2362,12 +2362,8 @@ ctnetlink_glue_attach_expect(const struct nlattr *attr, struct nf_conn *ct,
 		return PTR_ERR(exp);
 		return PTR_ERR(exp);
 
 
 	err = nf_ct_expect_related_report(exp, portid, report);
 	err = nf_ct_expect_related_report(exp, portid, report);
-	if (err < 0) {
-		nf_ct_expect_put(exp);
-		return err;
-	}
-
-	return 0;
+	nf_ct_expect_put(exp);
+	return err;
 }
 }
 
 
 static void ctnetlink_glue_seqadj(struct sk_buff *skb, struct nf_conn *ct,
 static void ctnetlink_glue_seqadj(struct sk_buff *skb, struct nf_conn *ct,