]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
lightnvm: fix memory leak when submit fails
authorPan Bian <bianpan2016@163.com>
Thu, 21 Jan 2021 07:22:02 +0000 (23:22 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jan 2021 10:47:53 +0000 (11:47 +0100)
commit 97784481757fba7570121a70dd37ca74a29f50a8 upstream.

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: aff3fb18f957 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/lightnvm/core.c

index a2ebc75af8c7970564a6f96637f6c401f7f96c45..4714aa936b2a212855c6c553249ef47c3ee07542 100644 (file)
@@ -849,11 +849,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;
 }