Netdev List
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: Can Peng <pengcan@kylinos.cn>, <manishc@marvell.com>,
	<rahulv@marvell.com>, <GR-Linux-NIC-Dev@marvell.com>,
	<andrew+netdev@lunn.ch>, <davem@davemloft.net>,
	<edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] netxen: unregister notifiers if PCI registration fails
Date: Wed, 29 Jul 2026 16:06:17 -0700	[thread overview]
Message-ID: <1bb991a9-cf32-48ef-b009-ce9ed8e8a4de@intel.com> (raw)
In-Reply-To: <20260728032046.121631-2-pengcan@kylinos.cn>

On 7/27/2026 8:20 PM, Can Peng wrote:
> netxen_init_module() registers the netdevice and inetaddr notifiers before
> registering the PCI driver.  If pci_register_driver() fails, the function
> returns the error directly and leaves both notifiers registered.
> 

I'm curious why it registers the netdevice and inetaddr notifiers first
before the PCI driver? I guess it doesn't really matter which order but
you'd want to change the teardown order in remove if you switched it.
> That leaves notifier callbacks installed for a module that failed to load.
> Mirror the module exit path on this failure and unregister the notifiers
> before returning the error.
> 
> Fixes: 6598b169b856 ("netxen: enable ip addr hashing")
> Signed-off-by: Can Peng <pengcan@kylinos.cn>
> ---

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

>  .../net/ethernet/qlogic/netxen/netxen_nic_main.c    | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
> index 5ee2bd9d6886..67d9bf69f8f2 100644
> --- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
> +++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
> @@ -3447,13 +3447,24 @@ static struct pci_driver netxen_driver = {
>  
>  static int __init netxen_init_module(void)
>  {
> +	int ret;
> +
>  	printk(KERN_INFO "%s\n", netxen_nic_driver_string);
>  
>  #ifdef CONFIG_INET
>  	register_netdevice_notifier(&netxen_netdev_cb);
>  	register_inetaddr_notifier(&netxen_inetaddr_cb);
>  #endif
> -	return pci_register_driver(&netxen_driver);
> +
> +	ret = pci_register_driver(&netxen_driver);
> +#ifdef CONFIG_INET
> +	if (ret) {
> +		unregister_inetaddr_notifier(&netxen_inetaddr_cb);
> +		unregister_netdevice_notifier(&netxen_netdev_cb);
> +	}
> +#endif

Normally i'd suggest a goto cleanup error pattern, but this is a small
function without much worth to do that.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

> +
> +	return ret;
>  }
>  
>  module_init(netxen_init_module);


  reply	other threads:[~2026-07-29 23:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28  3:20 [PATCH 0/2] qlogic: fix and tidy notifier cleanup paths Can Peng
2026-07-28  3:20 ` [PATCH 1/2] netxen: unregister notifiers if PCI registration fails Can Peng
2026-07-29 23:06   ` Jacob Keller [this message]
2026-07-28  3:20 ` [PATCH 2/2] qlcnic: move notifier error cleanup under CONFIG_INET Can Peng
2026-07-29 23:38   ` Jacob Keller

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=1bb991a9-cf32-48ef-b009-ce9ed8e8a4de@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=GR-Linux-NIC-Dev@marvell.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manishc@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pengcan@kylinos.cn \
    --cc=rahulv@marvell.com \
    /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