diff options
author | Joseph Qi <joseph.qi@huawei.com> | 2013-09-11 17:20:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-11 18:56:50 -0400 |
commit | 03dbe88aa9cd0d7b0a876b38bd75ce73b4522454 (patch) | |
tree | 2adc8eb4f283cc2ffa3f6903e074f634c3f4a78f /fs/ocfs2/cluster/tcp.c | |
parent | 9a239e4c68df78888f67b1d4e7d507e24ac6764f (diff) |
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>
Diffstat (limited to 'fs/ocfs2/cluster/tcp.c')
-rw-r--r-- | fs/ocfs2/cluster/tcp.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 8c50c238577a..2cd2406b4140 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c | |||
@@ -1873,12 +1873,16 @@ static int o2net_accept_one(struct socket *sock) | |||
1873 | 1873 | ||
1874 | if (o2nm_this_node() >= node->nd_num) { | 1874 | if (o2nm_this_node() >= node->nd_num) { |
1875 | local_node = o2nm_get_node_by_num(o2nm_this_node()); | 1875 | local_node = o2nm_get_node_by_num(o2nm_this_node()); |
1876 | printk(KERN_NOTICE "o2net: Unexpected connect attempt seen " | 1876 | if (local_node) |
1877 | "at node '%s' (%u, %pI4:%d) from node '%s' (%u, " | 1877 | printk(KERN_NOTICE "o2net: Unexpected connect attempt " |
1878 | "%pI4:%d)\n", local_node->nd_name, local_node->nd_num, | 1878 | "seen at node '%s' (%u, %pI4:%d) from " |
1879 | &(local_node->nd_ipv4_address), | 1879 | "node '%s' (%u, %pI4:%d)\n", |
1880 | ntohs(local_node->nd_ipv4_port), node->nd_name, | 1880 | local_node->nd_name, local_node->nd_num, |
1881 | node->nd_num, &sin.sin_addr.s_addr, ntohs(sin.sin_port)); | 1881 | &(local_node->nd_ipv4_address), |
1882 | ntohs(local_node->nd_ipv4_port), | ||
1883 | node->nd_name, | ||
1884 | node->nd_num, &sin.sin_addr.s_addr, | ||
1885 | ntohs(sin.sin_port)); | ||
1882 | ret = -EINVAL; | 1886 | ret = -EINVAL; |
1883 | goto out; | 1887 | goto out; |
1884 | } | 1888 | } |