[PATCH 5.8 06/56] cxgb4: fix memory leak during module unload

From: Greg Kroah-Hartman
Date: Fri Sep 25 2020 - 08:58:12 EST


From: Raju Rangoju <rajur@xxxxxxxxxxx>

[ Upstream commit f4a26a9b311d7ff9db461278faf2869d06496ef8 ]

Fix the memory leak in mps during module unload
path by freeing mps reference entries if the list
adpter->mps_ref is not already empty

Fixes: 28b3870578ef ("cxgb4: Re-work the logic for mps refcounting")
Signed-off-by: Raju Rangoju <rajur@xxxxxxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_mps.c
@@ -229,7 +229,7 @@ void cxgb4_free_mps_ref_entries(struct a
{
struct mps_entries_ref *mps_entry, *tmp;

- if (!list_empty(&adap->mps_ref))
+ if (list_empty(&adap->mps_ref))
return;

spin_lock(&adap->mps_ref_lock);