vsock: always call vsock_init_tables()
authorCong Wang <xiyou.wangcong@gmail.com>
Tue, 24 Oct 2017 22:30:37 +0000 (15:30 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 26 Oct 2017 08:45:58 +0000 (17:45 +0900)
commitc1eef220c1760762753b602c382127bfccee226d
treee2a603686a2f0957a209cc553055b0364cbed72a
parent3c91b0c1de8d013490bbc41ce9ee8810ea5baddd
vsock: always call vsock_init_tables()

Although CONFIG_VSOCKETS_DIAG depends on CONFIG_VSOCKETS,
vsock_init_tables() is not always called, it is called only
if other modules call its caller. Therefore if we only
enable CONFIG_VSOCKETS_DIAG, it would crash kernel on uninitialized
vsock_bind_table.

This patch fixes it by moving vsock_init_tables() to its own
module_init().

Fixes: 413a4317aca7 ("VSOCK: add sock_diag interface")
Reported-by: syzkaller bot
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Jorgen Hansen <jhansen@vmware.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/vmw_vsock/af_vsock.c