Skip to content

Commit

Permalink
[NETFILTER]: ipt_recent: avoid a possible NULL pointer deref in recen…
Browse files Browse the repository at this point in the history
…t_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>
  • Loading branch information
Jesper Juhl authored and David S. Miller committed Aug 8, 2007
1 parent 864c5a4 commit 3af8e31
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion net/ipv4/netfilter/ipt_recent.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,12 +387,17 @@ static int recent_seq_open(struct inode *inode, struct file *file)
st = kzalloc(sizeof(*st), GFP_KERNEL);
if (st == NULL)
return -ENOMEM;

ret = seq_open(file, &recent_seq_ops);
if (ret)
if (ret) {
kfree(st);
goto out;
}

st->table = pde->data;
seq = file->private_data;
seq->private = st;
out:
return ret;
}

Expand Down

0 comments on commit 3af8e31

Please sign in to comment.