mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: Myeonghun Pak <mhun512@gmail.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Ijae Kim <ae878000@gmail.com>
Subject: Re: [PATCH 1/2] tty: moxa: unwind tty driver if PCI registration fails
Date: Mon, 3 Aug 2026 08:06:58 +0200	[thread overview]
Message-ID: <908e828b-1fbc-4a44-8718-f0e7459b6ed1@kernel.org> (raw)
In-Reply-To: <20260731161809.45066-1-mhun512@gmail.com>

On 31. 07. 26, 18:18, Myeonghun Pak wrote:
> moxa_init() registers the tty driver before registering the PCI driver.
> If pci_register_driver() fails, module initialization returns without
> unregistering the tty driver or dropping its reference. moxa_exit() is
> not called after a failed module initialization.
> 
> Unregister the tty driver and drop its reference before returning the
> PCI registration error.
I think, we should remove the whole driver instead:
https://lore.kernel.org/all/2da84e36-7ac6-407d-8e08-edca82f4cbce@kernel.org/

> ---
>   drivers/tty/moxa.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
> index 1bb2376af85c..680b2dd65462 100644
> --- a/drivers/tty/moxa.c
> +++ b/drivers/tty/moxa.c
> @@ -1172,8 +1172,11 @@ static int __init moxa_init(void)
>   	}
>   
>   	retval = pci_register_driver(&moxa_pci_driver);
> -	if (retval)
> +	if (retval) {
>   		printk(KERN_ERR "Can't register MOXA pci driver!\n");
> +		tty_unregister_driver(moxaDriver);
> +		tty_driver_kref_put(moxaDriver);
> +	}
>   
>   	return retval;
>   }


-- 
js
suse labs

  parent reply	other threads:[~2026-08-03  6:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 16:18 Myeonghun Pak
2026-07-31 16:18 ` [PATCH 2/2] tty: moxa: use pcim_enable_device() Myeonghun Pak
2026-08-03  6:06 ` Jiri Slaby [this message]
2026-08-03 12:41   ` [PATCH 1/2] tty: moxa: unwind tty driver if PCI registration fails Greg Kroah-Hartman
2026-08-04 13:55     ` Myeonghun Pak

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=908e828b-1fbc-4a44-8718-f0e7459b6ed1@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=ae878000@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mhun512@gmail.com \
    --cc=stable@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®