Skip to content

Commit

Permalink
lightnvm: fix memory leak when submit fails
Browse files Browse the repository at this point in the history
The allocated page is not released if error occurs in
nvm_submit_io_sync_raw(). __free_page() is moved ealier to avoid
possible memory leak issue.

Fixes: aff3fb1 ("lightnvm: move bad block and chunk state logic to core")
Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Pan Bian authored and Jens Axboe committed Jan 21, 2021
1 parent 1df35bf commit 9778448
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/lightnvm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,11 +844,10 @@ static int nvm_bb_chunk_sense(struct nvm_dev *dev, struct ppa_addr ppa)
rqd.ppa_addr = generic_to_dev_addr(dev, ppa);

ret = nvm_submit_io_sync_raw(dev, &rqd);
__free_page(page);
if (ret)
return ret;

__free_page(page);

return rqd.error;
}

Expand Down

0 comments on commit 9778448

Please sign in to comment.