From: Jiri Slaby <jirislaby@kernel.org>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
gregkh@linuxfoundation.org, akpm@linux-foundation.org,
stefani@seibold.net
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] tty: nozomi: Fix a resource leak in an error handling function
Date: Mon, 10 May 2021 11:51:16 +0200 [thread overview]
Message-ID: <749cb98d-07d6-740e-1d2d-46306520089b@kernel.org> (raw)
In-Reply-To: <4f0d2b3038e82f081d370ccb0cade3ad88463fe7.1620580838.git.christophe.jaillet@wanadoo.fr>
On 09. 05. 21, 19:22, Christophe JAILLET wrote:
> A 'request_irq()' call is not balanced by a corresponding 'free_irq()' in
> the error handling path, as already done in the remove function.
>
> Add it.
>
> Fixes: 9842c38e9176 ("kfifo: fix warn_unused_result")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
> ---
> I also wonder if the loop above is correct. The 'i < MAX_PORT' looks really
> spurious to me.
> 'tty_port_destroy' can be called twice for the same entry (once before
> branching in the error handling path, and once in here) and
> 'tty_unregister_device'/'tty_port_destroy' will be called on entries
> that have not been 'tty_port_init'ed or 'tty_port_register_device'd.
> I don't know if it may be an issue.
Yes. The fail path handling is very broken there. Both the code of
err_free_tty label, and of the err_free_kfifo label. The loops should
have been _something_ (I didn't invest much thinking into it, so it's
likely wrong) like:
for (i--; i--; ) {
...
}
> ---
> drivers/tty/nozomi.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
> index 9a2d78ace49b..b270e137ef9b 100644
> --- a/drivers/tty/nozomi.c
> +++ b/drivers/tty/nozomi.c
> @@ -1420,6 +1420,7 @@ static int nozomi_card_init(struct pci_dev *pdev,
> tty_unregister_device(ntty_driver, dc->index_start + i);
> tty_port_destroy(&dc->port[i].port);
> }
> + free_irq(pdev->irq, dc);
> err_free_kfifo:
> for (i = 0; i < MAX_PORT; i++)
> kfifo_free(&dc->port[i].fifo_ul);
>
thanks,
--
js
suse labs
prev parent reply other threads:[~2021-05-10 9:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-09 17:22 [PATCH] tty: nozomi: Fix a resource leak in an error handling function Christophe JAILLET
2021-05-10 6:35 ` Dan Carpenter
2021-05-10 9:51 ` 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=749cb98d-07d6-740e-1d2d-46306520089b@kernel.org \
--to=jirislaby@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stefani@seibold.net \
/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;
as well as URLs for NNTP newsgroup(s).