Re: [PATCH] tty: n_null: remove legacy BUG_ON() from module initialization

From: Greg KH

Date: Sun Nov 08 2026 - 08:44:26 EST


On Sun, Nov 08, 2026 at 03:50:31PM +0300, Bramwel Barack wrote:
> The use of BUG_ON() in module initialization paths is heavily deprecated
> as it triggers a kernel panic and crashes the entire system for non-fatal
> registration failures. If tty_register_ldisc() fails (e.g., if the slot
> is already occupied), it should be handled gracefully.
>
> Modernize the initialization path by capturing the return value of
> tty_register_ldisc(), logging a clean error message via pr_err(), and
> propagating the error code back up to the module loader.

Nice try, but no, this isn't going to work at all. Please test this by
actually testing if this code path can ever fail. (hint, look in the
mailing list archives...)

Why did you decide to make this change if you can't ever hit it?

thanks,


greg k-h