Re: [PATCH] tty: nozomi: Fix a resource leak in an error handling function

From: Dan Carpenter
Date: Mon May 10 2021 - 02:35:55 EST


On Sun, May 09, 2021 at 07:22:33PM +0200, 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@xxxxxxxxxx>
> ---
> 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.


Calling tty_port_destroy() twice is fine, but I think calling
tty_unregister_device() for unregistered devices will lead to a NULL
dereference in cdev_del().

regards,
dan carpenter