mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
net: mvpp2: fix mvpp2 debugfs leak
When mvpp2 is unloaded, the driver specific debugfs directory is not removed, which technically leads to a memory leak. However, this directory is only created when the first device is probed, so the hardware is present. Removing the module is only something a developer would to when e.g. testing out changes, so the module would be reloaded. So this memory leak is minor. The original attempt in commitfe2c9c61f6
("net: mvpp2: debugfs: fix memory leak when using debugfs_lookup()") that was labelled as a memory leak fix was not, it fixed a refcount leak, but in doing so created a problem when the module is reloaded - the directory already exists, but mvpp2_root is NULL, so we lose all debugfs entries. This fix has been reverted. This is the alternative fix, where we remove the offending directory whenever the driver is unloaded. Fixes:21da57a231
("net: mvpp2: add a debugfs interface for the Header Parser") Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Marcin Wojtas <mw@semihalf.com> Link: https://lore.kernel.org/r/E1ofOAB-00CzkG-UO@rmk-PC.armlinux.org.uk Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
93e2be344a
commit
0152dfee23
@ -1530,6 +1530,7 @@ u32 mvpp2_read(struct mvpp2 *priv, u32 offset);
|
||||
void mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name);
|
||||
|
||||
void mvpp2_dbgfs_cleanup(struct mvpp2 *priv);
|
||||
void mvpp2_dbgfs_exit(void);
|
||||
|
||||
void mvpp23_rx_fifo_fc_en(struct mvpp2 *priv, int port, bool en);
|
||||
|
||||
|
@ -691,6 +691,13 @@ static int mvpp2_dbgfs_port_init(struct dentry *parent,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct dentry *mvpp2_root;
|
||||
|
||||
void mvpp2_dbgfs_exit(void)
|
||||
{
|
||||
debugfs_remove(mvpp2_root);
|
||||
}
|
||||
|
||||
void mvpp2_dbgfs_cleanup(struct mvpp2 *priv)
|
||||
{
|
||||
debugfs_remove_recursive(priv->dbgfs_dir);
|
||||
@ -700,10 +707,9 @@ void mvpp2_dbgfs_cleanup(struct mvpp2 *priv)
|
||||
|
||||
void mvpp2_dbgfs_init(struct mvpp2 *priv, const char *name)
|
||||
{
|
||||
struct dentry *mvpp2_dir, *mvpp2_root;
|
||||
struct dentry *mvpp2_dir;
|
||||
int ret, i;
|
||||
|
||||
mvpp2_root = debugfs_lookup(MVPP2_DRIVER_NAME, NULL);
|
||||
if (!mvpp2_root)
|
||||
mvpp2_root = debugfs_create_dir(MVPP2_DRIVER_NAME, NULL);
|
||||
|
||||
|
@ -7706,7 +7706,18 @@ static struct platform_driver mvpp2_driver = {
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(mvpp2_driver);
|
||||
static int __init mvpp2_driver_init(void)
|
||||
{
|
||||
return platform_driver_register(&mvpp2_driver);
|
||||
}
|
||||
module_init(mvpp2_driver_init);
|
||||
|
||||
static void __exit mvpp2_driver_exit(void)
|
||||
{
|
||||
platform_driver_unregister(&mvpp2_driver);
|
||||
mvpp2_dbgfs_exit();
|
||||
}
|
||||
module_exit(mvpp2_driver_exit);
|
||||
|
||||
MODULE_DESCRIPTION("Marvell PPv2 Ethernet Driver - www.marvell.com");
|
||||
MODULE_AUTHOR("Marcin Wojtas <mw@semihalf.com>");
|
||||
|
Loading…
Reference in New Issue
Block a user