]> git.baikalelectronics.ru Git - kernel.git/commit
sctp: fix error path in sctp_stream_init
authorMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Tue, 2 Jan 2018 21:44:37 +0000 (19:44 -0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 3 Jan 2018 16:29:42 +0000 (11:29 -0500)
commit6499159e4cb26490dc2d96bccae321f0d97c4511
tree6edb4a6cc1a852af40a183d6b7e7dcedaaafa046
parent61f2a819eb3390fdd486004c9844528660a174db
sctp: fix error path in sctp_stream_init

syzbot noticed a NULL pointer dereference panic in sctp_stream_free()
which was caused by an incomplete error handling in sctp_stream_init().
By not clearing stream->outcnt, it made a for() in sctp_stream_free()
think that it had elements to free, but not, leading to the panic.

As suggested by Xin Long, this patch also simplifies the error path by
moving it to the only if() that uses it.

See-also: https://www.spinics.net/lists/netdev/msg473756.html
See-also: https://www.spinics.net/lists/netdev/msg465024.html
Reported-by: syzbot <syzkaller@googlegroups.com>
Fixes: ebe85f5c1447 ("sctp: introduce struct sctp_stream_out_ext")
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/stream.c