Skip to contentSkip to conversation

lightnvm: fix possible memory leak in nvme_nvm_get_l2p_tbl()

PATCH New Wei Yongjun 1 participant 1 message Feb 5, 2017 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lightnvm: fix possible memory leak in nvme_nvm_get_l2p_tbl()

From: Wei Yongjun <[email protected]>

'entries' is malloced in nvme_nvm_get_l2p_tbl() and should be freed before leaving from the error handling cases, otherwise it will cause memory leak.

Fixes 8e79b5cb1d3b ("lightnvm: move block provisioning to targets")
Signed-off-by Wei Yongjun <weiyongjun1 at huawei.com>
---
 drivers/nvme/host/lightnvm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/lightnvm.c +2 -1
index 588d4a3..2388716 100644
@@ -368,7 +368,8 @@ static int nvme_nvm_get_l2p_tbl(struct nvm_dev *nvmdev, u64 slba, u32 nlb,
 
 		if (unlikely(elba > nvmdev->total_secs)) {
 			pr_err("nvm: L2P data from device is out of bounds!\n");
-			return -EINVAL;
+			ret = -EINVAL;
+			goto out;
 		}
 
 		/* Transform physical address to target address space */