diff options
author | Leon Yu <chianglungyu@gmail.com> | 2014-06-01 01:37:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-06-02 20:49:45 -0400 |
commit | 418c96ac151a16a5094a95d14252c92c1d47ec67 (patch) | |
tree | cbe75d2edab13883541e85522ecdec063785b22d /net | |
parent | 3aab01d800eb195de3f273d9a195fe070a507d56 (diff) |
net: filter: fix possible memory leak in __sk_prepare_filter()
__sk_prepare_filter() was reworked in commit bd4cf0ed3 (net: filter:
rework/optimize internal BPF interpreter's instruction set) so that it should
have uncharged memory once things went wrong. However that work isn't complete.
Error is handled only in __sk_migrate_filter() while memory can still leak in
the error path right after sk_chk_filter().
Fixes: bd4cf0ed331a ("net: filter: rework/optimize internal BPF interpreter's instruction set")
Signed-off-by: Leon Yu <chianglungyu@gmail.com>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Tested-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/filter.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/net/core/filter.c b/net/core/filter.c index 9d79ca0a6e8e..4aec7b93f1a9 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
@@ -1559,8 +1559,13 @@ static struct sk_filter *__sk_prepare_filter(struct sk_filter *fp, | |||
1559 | fp->jited = 0; | 1559 | fp->jited = 0; |
1560 | 1560 | ||
1561 | err = sk_chk_filter(fp->insns, fp->len); | 1561 | err = sk_chk_filter(fp->insns, fp->len); |
1562 | if (err) | 1562 | if (err) { |
1563 | if (sk != NULL) | ||
1564 | sk_filter_uncharge(sk, fp); | ||
1565 | else | ||
1566 | kfree(fp); | ||
1563 | return ERR_PTR(err); | 1567 | return ERR_PTR(err); |
1568 | } | ||
1564 | 1569 | ||
1565 | /* Probe if we can JIT compile the filter and if so, do | 1570 | /* Probe if we can JIT compile the filter and if so, do |
1566 | * the compilation of the filter. | 1571 | * the compilation of the filter. |