From: Jiri Slaby <jslaby@suse.cz>
To: Takashi Iwai <tiwai@suse.de>
Cc: Samo Pogacnik <samo_pogacnik@t-2.net>,
Jean Delvare <jdelvare@suse.de>, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Struan Bartlett <struan.bartlett@gmail.com>,
Andreas Schwab <schwab@linux-m68k.org>,
gnomes@lxorguk.ukuu.org.uk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] ttyprintk: Fix wrong tty_unregister_driver() call in the error path
Date: Thu, 03 Apr 2014 10:00:26 +0200 [thread overview]
Message-ID: <533D151A.9070808@suse.cz> (raw)
In-Reply-To: <s5hbnwjdjtf.wl%tiwai@suse.de>
On 04/03/2014 08:10 AM, Takashi Iwai wrote:
> At Wed, 02 Apr 2014 14:24:33 +0200,
> Jean Delvare wrote:
>>
>> Le Wednesday 02 April 2014 à 12:29 +0200, Takashi Iwai a écrit :
>>> ttyprintk driver calls tty_unregister_driver() wrongly in the error
>>> path of tty_register_driver(). Also, setting ttyprintk_driver to NULL
>>> is utterly superfluous, so let's get rid of it, too.
>>>
>>> Reported-by: Jean Delvare <jdelvare@suse.de>
>>> Signed-off-by: Takashi Iwai <tiwai@suse.de>
>>> ---
>>> drivers/char/ttyprintk.c | 2 --
>>> 1 file changed, 2 deletions(-)
>>>
>>> diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
>>> index daea84c41743..2a39c5790364 100644
>>> --- a/drivers/char/ttyprintk.c
>>> +++ b/drivers/char/ttyprintk.c
>>> @@ -210,10 +210,8 @@ static int __init ttyprintk_init(void)
>>> return 0;
>>>
>>> error:
>>> - tty_unregister_driver(ttyprintk_driver);
>>> put_tty_driver(ttyprintk_driver);
>>> tty_port_destroy(&tpk_port.port);
>>> - ttyprintk_driver = NULL;
>>> return ret;
>>> }
>>> device_initcall(ttyprintk_init);
>>
>> Reviewed-by: Jean Delvare <jdelvare@suse.de>
>
> Meanwhile, I found that tty_unregister_driver() was added
> intentionally in the commit f06fb543c1d0,
> TTY: ttyprintk, unregister tty driver on failure
>
> When the tty_printk driver fails to create a node in sysfs, the
> system
> crashes. It is because the driver registers a tty driver and frees
> it
> without deregistering it first. The fix is easy: add a call to
> tty_unregister_driver to the fail path.
>
> But, I failed to see why this is needed in the current code.
>
> Jiri, is your fix still valid at all?
The code was different. There was also device_create after
tty_register_driver. I must admit that I don't know why I didn't change
'goto error' in the tty_register_driver fail path.
ret = tty_register_driver(ttyprintk_driver);
if (ret < 0) {
printk(KERN_ERR "Couldn't register ttyprintk driver\n");
goto error;
}
/* create our unnumbered device */
rp = device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 3), NULL,
ttyprintk_driver->name);
if (IS_ERR(rp)) {
printk(KERN_ERR "Couldn't create ttyprintk device\n");
ret = PTR_ERR(rp);
goto error;
}
So yes, there should be no tty_unregister_driver in the fail path when
device_create is gone now.
thanks,
--
js
suse labs
prev parent reply other threads:[~2014-04-03 8:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-02 10:29 [PATCH 1/2] ttyprintk: Fix wrong tty_unregister_driver() call in the error path Takashi Iwai
2014-04-02 10:29 ` [PATCH 2/2] ttyprintk: Allow built as a module Takashi Iwai
2014-04-02 12:31 ` Jean Delvare
2014-04-02 12:42 ` Takashi Iwai
2014-04-02 19:32 ` Greg Kroah-Hartman
2014-04-03 6:13 ` Takashi Iwai
2014-04-05 11:15 ` Samo Pogačnik
2014-04-02 12:24 ` [PATCH 1/2] ttyprintk: Fix wrong tty_unregister_driver() call in the error path Jean Delvare
2014-04-03 6:10 ` Takashi Iwai
2014-04-03 8:00 ` Jiri Slaby [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=533D151A.9070808@suse.cz \
--to=jslaby@suse.cz \
--cc=arnd@arndb.de \
--cc=gnomes@lxorguk.ukuu.org.uk \
--cc=gregkh@linuxfoundation.org \
--cc=jdelvare@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=samo_pogacnik@t-2.net \
--cc=schwab@linux-m68k.org \
--cc=struan.bartlett@gmail.com \
--cc=tiwai@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox