From: Jesper Juhl Date: Wed, 8 Aug 2007 01:10:54 +0000 (-0700) Subject: [NETFILTER]: ipt_recent: avoid a possible NULL pointer deref in recent_seq_open() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3af8e31cf57646284b5f77f9d57d2c22fa77485a;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git [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 Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- 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) 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; }