[PATCH] scsi: csiostor: Fix memory leak in csio_wr_eq_destroy()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



mempool_alloc() allocates an element for mbp from a specific memory pool.
When some error occurs, we should free this memory pool with
mempool_free(). But when cbfn != NULL, the function returns 0 without
freeing the mbp, which will lead to a memory leak.

We can fix it by calling mempool_free() when the cbfn != NULL.

Signed-off-by: Jianglei Nie <niejianglei2021@xxxxxxx>
---
 drivers/scsi/csiostor/csio_wr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/csiostor/csio_wr.c b/drivers/scsi/csiostor/csio_wr.c
index fe0355c964bc..7dcc4fda0483 100644
--- a/drivers/scsi/csiostor/csio_wr.c
+++ b/drivers/scsi/csiostor/csio_wr.c
@@ -728,8 +728,10 @@ csio_wr_eq_destroy(struct csio_hw *hw, void *priv, int eq_idx,
 		return rv;
 	}
 
-	if (cbfn != NULL)
+	if (cbfn != NULL) {
+		mempool_free(mbp, hw->mb_mempool);
 		return 0;
+	}
 
 	return csio_wr_eq_destroy_rsp(hw, mbp, eq_idx);
 }
-- 
2.25.1




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux