summaryrefslogtreecommitdiffstats
path: root/net/tipc/socket.c
diff options
context:
space:
mode:
authorJon Maloy <jon.maloy@ericsson.com>2018-04-11 19:15:48 -0400
committerDavid S. Miller <davem@davemloft.net>2018-04-12 21:55:38 -0400
commit335b929b28aeb5bfc0698adb21deaf685b2982d1 (patch)
treef6978c9de4fd5c6d35c0a4faf3400df5a29820c1 /net/tipc/socket.c
parent9d0c75bf6e03d9bf80c55b0f677dc9b982958fd5 (diff)
tipc: fix missing initializer in tipc_sendmsg()
The stack variable 'dnode' in __tipc_sendmsg() may theoretically end up tipc_node_get_mtu() as an unitilalized variable. We fix this by intializing the variable at declaration. We also add a default else clause to the two conditional ones already there, so that we never end up in the named function if the given address type is illegal. Reported-by: syzbot+b0975ce9355b347c1546@syzkaller.appspotmail.com Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r--net/tipc/socket.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 1fd1c8b5ce03..252a52ae0893 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1278,7 +1278,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)
1278 struct tipc_msg *hdr = &tsk->phdr; 1278 struct tipc_msg *hdr = &tsk->phdr;
1279 struct tipc_name_seq *seq; 1279 struct tipc_name_seq *seq;
1280 struct sk_buff_head pkts; 1280 struct sk_buff_head pkts;
1281 u32 dnode, dport; 1281 u32 dport, dnode = 0;
1282 u32 type, inst; 1282 u32 type, inst;
1283 int mtu, rc; 1283 int mtu, rc;
1284 1284
@@ -1348,6 +1348,8 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)
1348 msg_set_destnode(hdr, dnode); 1348 msg_set_destnode(hdr, dnode);
1349 msg_set_destport(hdr, dest->addr.id.ref); 1349 msg_set_destport(hdr, dest->addr.id.ref);
1350 msg_set_hdr_sz(hdr, BASIC_H_SIZE); 1350 msg_set_hdr_sz(hdr, BASIC_H_SIZE);
1351 } else {
1352 return -EINVAL;
1351 } 1353 }
1352 1354
1353 /* Block or return if destination link is congested */ 1355 /* Block or return if destination link is congested */