Skip to content

Commit 335b929

Browse files
Jon Maloydavem330
authored andcommitted
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: [email protected] Signed-off-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9d0c75b commit 335b929

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/tipc/socket.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)
12781278
struct tipc_msg *hdr = &tsk->phdr;
12791279
struct tipc_name_seq *seq;
12801280
struct sk_buff_head pkts;
1281-
u32 dnode, dport;
1281+
u32 dport, dnode = 0;
12821282
u32 type, inst;
12831283
int mtu, rc;
12841284

@@ -1348,6 +1348,8 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dlen)
13481348
msg_set_destnode(hdr, dnode);
13491349
msg_set_destport(hdr, dest->addr.id.ref);
13501350
msg_set_hdr_sz(hdr, BASIC_H_SIZE);
1351+
} else {
1352+
return -EINVAL;
13511353
}
13521354

13531355
/* Block or return if destination link is congested */

0 commit comments

Comments
 (0)