diff options
author | Jesper Juhl <jesper.juhl@gmail.com> | 2007-08-07 21:10:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-08-07 21:10:54 -0400 |
commit | 3af8e31cf57646284b5f77f9d57d2c22fa77485a (patch) | |
tree | 4c39d509d0c6db9e2bfdbabc8f4be66d3795d308 | |
parent | 864c5a4d37b1f25e3c36dd00a09158eae455a8fd (diff) |
[NETFILTER]: ipt_recent: avoid a possible NULL pointer deref in recent_seq_open()
If the call to seq_open() returns != 0 then the code calls
kfree(st) but then on the very next line proceeds to
dereference the pointer - not good.
Problem spotted by the Coverity checker.
Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/netfilter/ipt_recent.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/net/ipv4/netfilter/ipt_recent.c b/net/ipv4/netfilter/ipt_recent.c index 321804315659..6d0c0f7364ad 100644 --- a/net/ipv4/netfilter/ipt_recent.c +++ b/net/ipv4/netfilter/ipt_recent.c | |||
@@ -387,12 +387,17 @@ static int recent_seq_open(struct inode *inode, struct file *file) | |||
387 | st = kzalloc(sizeof(*st), GFP_KERNEL); | 387 | st = kzalloc(sizeof(*st), GFP_KERNEL); |
388 | if (st == NULL) | 388 | if (st == NULL) |
389 | return -ENOMEM; | 389 | return -ENOMEM; |
390 | |||
390 | ret = seq_open(file, &recent_seq_ops); | 391 | ret = seq_open(file, &recent_seq_ops); |
391 | if (ret) | 392 | if (ret) { |
392 | kfree(st); | 393 | kfree(st); |
394 | goto out; | ||
395 | } | ||
396 | |||
393 | st->table = pde->data; | 397 | st->table = pde->data; |
394 | seq = file->private_data; | 398 | seq = file->private_data; |
395 | seq->private = st; | 399 | seq->private = st; |
400 | out: | ||
396 | return ret; | 401 | return ret; |
397 | } | 402 | } |
398 | 403 | ||