Re: [PATCH v3 4/5] console: Avoid positive return code from unregister_console()

From: Andy Shevchenko
Date: Tue Jan 28 2020 - 04:23:55 EST


On Tue, Jan 28, 2020 at 01:43:32PM +0900, Sergey Senozhatsky wrote:
> On (20/01/27 13:47), Andy Shevchenko wrote:
> [..]
> > res = _braille_unregister_console(console);
> > - if (res)
> > + if (res < 0)
> > return res;
> > + if (res > 0)
> > + return 0;
> >
> > - res = 1;
> > + res = -ENODEV;
> > console_lock();
> > if (console_drivers == console) {
> > console_drivers=console->next;
> > @@ -2838,6 +2840,9 @@ int unregister_console(struct console *console)
> > if (!res && (console->flags & CON_EXTENDED))
> > nr_ext_console_drivers--;
> >
> > + if (res && !(console->flags & CON_ENABLED))
> > + res = 0;
>
> Console is not on the console_drivers list. Why does !ENABLED case
> require extra handling?

It's mirroring (to some extend) the register_console() abort conditions.

> What about the case when console is ENABLED
> but still not registered?

What about when console is ENABLED and we call register_console()?
I think you can tell me what to do in these corner cases (however,
that's not the point of this series).

> I think that if the console is not on the list (was never registered)
> then we can just bail out, without console_sysfs_notify(), etc. IOW,
>
> if (res) {
> console->flags &= ~CON_ENABLED; /* just in case */
> console_unlock();
> return res;
> }

Perhaps. But see above. I would rather drop this condition for now
for sake of this series being to the point.

--
With Best Regards,
Andy Shevchenko