ocfs2: avoid possible NULL pointer dereference in o2net_accept_one()

Since o2nm_get_node_by_num() may return NULL, we add this check in
o2net_accept_one() to avoid possible NULL pointer dereference.

Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Joseph Qi 2013-09-11 14:20:01 -07:00 committed by Linus Torvalds
parent 9a239e4c68
commit 03dbe88aa9
1 changed files with 10 additions and 6 deletions

View File

@ -1873,12 +1873,16 @@ static int o2net_accept_one(struct socket *sock)
if (o2nm_this_node() >= node->nd_num) { if (o2nm_this_node() >= node->nd_num) {
local_node = o2nm_get_node_by_num(o2nm_this_node()); local_node = o2nm_get_node_by_num(o2nm_this_node());
printk(KERN_NOTICE "o2net: Unexpected connect attempt seen " if (local_node)
"at node '%s' (%u, %pI4:%d) from node '%s' (%u, " printk(KERN_NOTICE "o2net: Unexpected connect attempt "
"%pI4:%d)\n", local_node->nd_name, local_node->nd_num, "seen at node '%s' (%u, %pI4:%d) from "
&(local_node->nd_ipv4_address), "node '%s' (%u, %pI4:%d)\n",
ntohs(local_node->nd_ipv4_port), node->nd_name, local_node->nd_name, local_node->nd_num,
node->nd_num, &sin.sin_addr.s_addr, ntohs(sin.sin_port)); &(local_node->nd_ipv4_address),
ntohs(local_node->nd_ipv4_port),
node->nd_name,
node->nd_num, &sin.sin_addr.s_addr,
ntohs(sin.sin_port));
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }