Message ID | 20220512054709.12513-1-ap420073@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 1fa89ffbc04545b7582518e57f4b63e2a062870f |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net,v2] net: sfc: ef10: fix memory leak in efx_ef10_mtd_probe() | expand |
Hello: This patch was applied to netdev/net.git (master) by Jakub Kicinski <kuba@kernel.org>: On Thu, 12 May 2022 05:47:09 +0000 you wrote: > In the NIC ->probe() callback, ->mtd_probe() callback is called. > If NIC has 2 ports, ->probe() is called twice and ->mtd_probe() too. > In the ->mtd_probe(), which is efx_ef10_mtd_probe() it allocates and > initializes mtd partiion. > But mtd partition for sfc is shared data. > So that allocated mtd partition data from last called > efx_ef10_mtd_probe() will not be used. > Therefore it must be freed. > But it doesn't free a not used mtd partition data in efx_ef10_mtd_probe(). > > [...] Here is the summary with links: - [net,v2] net: sfc: ef10: fix memory leak in efx_ef10_mtd_probe() https://git.kernel.org/netdev/net/c/1fa89ffbc045 You are awesome, thank you!
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index 50d535981a35..f8edb3f1b73a 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c @@ -3579,6 +3579,11 @@ static int efx_ef10_mtd_probe(struct efx_nic *efx) n_parts++; } + if (!n_parts) { + kfree(parts); + return 0; + } + rc = efx_mtd_add(efx, &parts[0].common, n_parts, sizeof(*parts)); fail: if (rc)