]> git.baikalelectronics.ru Git - kernel.git/commit
sctp: fix memleak on err handling of stream initialization
authorMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Tue, 17 Dec 2019 01:01:16 +0000 (22:01 -0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Dec 2019 05:58:37 +0000 (21:58 -0800)
commit677cac304ac869a995ce6aa44c6563e5ab63d7d1
tree4f10faba719c2bcb1c89d8a5cde985090036fb10
parent8fa67b64650cc85c1e6398df1416e38c126b0391
sctp: fix memleak on err handling of stream initialization

syzbot reported a memory leak when an allocation fails within
genradix_prealloc() for output streams. That's because
genradix_prealloc() leaves initialized members initialized when the
issue happens and SCTP stack will abort the current initialization but
without cleaning up such members.

The fix here is to always call genradix_free() when genradix_prealloc()
fails, for output and also input streams, as it suffers from the same
issue.

Reported-by: syzbot+772d9e36c490b18d51d1@syzkaller.appspotmail.com
Fixes: 16800b3e4be4 ("sctp: convert to genradix")
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/stream.c