Re: [PATCH v2 2/2] tty: Fix race against tty_open() in tty_register_device_attr()

From: Jiri Slaby
Date: Tue Jun 03 2025 - 09:43:20 EST


On 02. 06. 25, 15:40, Max Staudt wrote:
On 6/2/25 19:31, Ilpo Järvinen wrote:
+    mutex_lock(&tty_mutex);

Use guard() so you don't need to change the returns and rollback path.

Thanks, I didn't know about this new kind of helper.

I'll leave it up to the TTY maintainers - if they don't express a preference for guard(),

I prefer guard(). Actually, I have a patchset to add a support for guard() for uart_lock and console_lock too and use it all over (incl. __free). They untangle the code on many places and get rid of much unneeded churn.

But in this very case, I see there is a label, I am not sure if it works right here. Try compiling with clang -- it will tell you. You likely won't cross the label with the guard().

thanks,
--
js
suse labs