]> git.baikalelectronics.ru Git - kernel.git/commit
sctp: fix err handling of stream initialization
authorMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Fri, 20 Dec 2019 18:03:44 +0000 (15:03 -0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 25 Dec 2019 00:07:10 +0000 (16:07 -0800)
commitf691418f2cdea932e12daa5e72fa1196ebc2a88f
treef0e38ebd703b0f10b9e84746d68ff8347d41a06d
parent90a136fdd59fd10ad5352a65e8db7aa004eda664
sctp: fix err handling of stream initialization

The fix on 677cac304ac8 fixed the issued reported there but introduced
another. When the allocation fails within sctp_stream_init() it is
okay/necessary to free the genradix. But it is also called when adding
new streams, from sctp_send_add_streams() and
sctp_process_strreset_addstrm_in() and in those situations it cannot
just free the genradix because by then it is a fully operational
association.

The fix here then is to only free the genradix in sctp_stream_init()
and on those other call sites  move on with what it already had and let
the subsequent error handling to handle it.

Tested with the reproducers from this report and the previous one,
with lksctp-tools and sctp-tests.

Reported-by: syzbot+9a1bc632e78a1a98488b@syzkaller.appspotmail.com
Fixes: 677cac304ac8 ("sctp: fix memleak on err handling of stream initialization")
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/stream.c