nvme: lightnvm: fix memory leak
authorRakesh Pandit <rakesh@tuxera.com>
Tue, 9 May 2017 14:48:25 +0000 (08:48 -0600)
committerJens Axboe <axboe@fb.com>
Wed, 10 May 2017 13:39:43 +0000 (07:39 -0600)
Free up kmalloc allocated memory if failure happens while handling L2P
table transfer in nvme_nvm_get_l2p_tbl.

Fixes: 8e79b5cb ("lightnvm: move block provisioning to targets")
Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
Reviewed-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/nvme/host/lightnvm.c

index 206bfdbc1c982b04ad41b52193ce4c6f4e5b2a5f..f5df78ed1e10974ffb9e239b57ce260f0bb5bae9 100644 (file)
@@ -367,7 +367,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 */