]> git.baikalelectronics.ru Git - kernel.git/commit
net: mvpp2: fix mvpp2 debugfs leak
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Mon, 3 Oct 2022 16:19:27 +0000 (17:19 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 26 Oct 2022 11:22:27 +0000 (13:22 +0200)
commit7e76e13576fd2dad4614577e0945081a03e846df
treeb98570568f92642238ff3514abb89f868b54ef80
parent85d3a3d8da28aa0ca182c7d4993add835a412821
net: mvpp2: fix mvpp2 debugfs leak

[ Upstream commit 05dabc8cb63e3892361605016fa2248efd1277ae ]

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 commit 5f23e1396e1f ("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: a8fd6ab05737 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/marvell/mvpp2/mvpp2.h
drivers/net/ethernet/marvell/mvpp2/mvpp2_debugfs.c
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c