lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180222025555.GA15024@lunn.ch>
Date:   Thu, 22 Feb 2018 03:55:55 +0100
From:   Andrew Lunn <andrew@...n.ch>
To:     Bryan Whitehead <Bryan.Whitehead@...rochip.com>
Cc:     davem@...emloft.net, UNGLinuxDriver@...rochip.com,
        netdev@...r.kernel.org
Subject: Re: [PATCH v2 net-next 1/2] lan743x: Add main source files for new
 lan743x driver

> +static void lan743x_intr_unregister_isr(struct lan743x_adapter *adapter,
> +					int vector_index)
> +{
> +	struct lan743x_vector *vector = &adapter->intr.vector_list
> +					[vector_index];
> +
> +	devm_free_irq(&adapter->pci.pdev->dev, vector->irq, vector);

Hu Bryan

The point of devm_ is that you don't need to free resources you have
allocated using devm_. The core will release them when the device is
removed.

In this case, you might want to ensure the hardware will not generate
any more interrupts, but you can leave the core to call free_irq().

Please look at all your devm_*free() like calls, and remove them if
they are not needed. 

> +static void lan743x_mdiobus_cleanup(struct lan743x_adapter *adapter)
> +{
> +	if (adapter->init_flags & LAN743X_INIT_FLAG_MDIOBUS_REGISTERED) {
> +		mdiobus_unregister(adapter->mdiobus);
> +		adapter->init_flags &= ~LAN743X_INIT_FLAG_MDIOBUS_REGISTERED;
> +	}
> +	if (adapter->init_flags & LAN743X_INIT_FLAG_MDIOBUS_ALLOCATED) {
> +		devm_mdiobus_free(&adapter->pci.pdev->dev, adapter->mdiobus);
> +		adapter->mdiobus = NULL;
> +		adapter->init_flags &= ~LAN743X_INIT_FLAG_MDIOBUS_ALLOCATED;
> +	}
> +}

So you can delete devm_mdiobus_free(). That probably means you can also remove 
LAN743X_INIT_FLAG_MDIOBUS_ALLOCATED.

> +
> +static void lan743x_full_cleanup(struct lan743x_adapter *adapter)
> +{
> +	if (adapter->init_flags & LAN743X_INIT_FLAG_NETDEV_REGISTERED) {
> +		unregister_netdev(adapter->netdev);
> +		adapter->init_flags &= ~LAN743X_INIT_FLAG_NETDEV_REGISTERED;
> +	}
> +	lan743x_mdiobus_cleanup(adapter);
> +	lan743x_hardware_cleanup(adapter);
> +	if (adapter->init_flags & LAN743X_COMPONENT_FLAG_PCI) {
> +		lan743x_pci_cleanup(adapter);
> +		adapter->init_flags &= ~LAN743X_COMPONENT_FLAG_PCI;
> +	}
> +
> +	/* would have freed netdev here.
> +	 * but netdev was allocated with devm_alloc_etherdev.
> +	 * and devm_free_netdev is not accessible.
> +	 * so it is expected to be freed by the devm subsystem.
> +	 */

And this comment can go.

    Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ