Re: [PATCH] tty: n_gsm: add missing tty_kref_put

From: Pavel Skripkin
Date: Tue Nov 09 2021 - 14:11:04 EST


On 11/9/21 20:33, Jiri Slaby wrote:
On 09. 11. 21, 11:39, Pavel Skripkin wrote:
My local syzbot instance hit memory leak in gsmld_attach_gsm(). The
reproducer injects allocation failure in tty_register_device(). After
this error only previous tty_register_device() calls unwinded, but not
tty_kref_get().

It leads to tty_struct leak, because ->close() won't be called in case
of ->open() failure and nothing puts tty reference.

I don't have time to check the n_gsm case now (like: are you talking
about tty->open/close or file_ops->open/close -- they behave
differently), but tty definitely calls close even if open fails.


Oh, I see now. I wasn't aware about this difference. Will do more detailed analysis of reported leak. Thank you for pointing it out!




With regards,
Pavel Skripkin