]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
lightnvm: fix partial read error path
authorIgor Konopko <igor.j.konopko@intel.com>
Fri, 1 Jun 2018 14:41:09 +0000 (16:41 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 3 Aug 2018 05:47:38 +0000 (07:47 +0200)
[ Upstream commit fbadca7396b97d95e2390c97506358f4f9dce7c7 ]

When error occurs during bio_add_page on partial read path, pblk
tries to free pages twice.

Signed-off-by: Igor Konopko <igor.j.konopko@intel.com>
Signed-off-by: Marcin Dziegielewski <marcin.dziegielewski@intel.com>
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/lightnvm/pblk-read.c

index 9eee10f69df0300632833f421b0ac4b0fa295b40..d528617c637b215566dbe809898dab2df2b546f3 100644 (file)
@@ -219,7 +219,7 @@ static int pblk_partial_read_bio(struct pblk *pblk, struct nvm_rq *rqd,
        new_bio = bio_alloc(GFP_KERNEL, nr_holes);
 
        if (pblk_bio_add_pages(pblk, new_bio, GFP_KERNEL, nr_holes))
-               goto err;
+               goto err_add_pages;
 
        if (nr_holes != new_bio->bi_vcnt) {
                pr_err("pblk: malformed bio\n");
@@ -310,10 +310,10 @@ static int pblk_partial_read_bio(struct pblk *pblk, struct nvm_rq *rqd,
        return NVM_IO_OK;
 
 err:
-       pr_err("pblk: failed to perform partial read\n");
-
        /* Free allocated pages in new bio */
-       pblk_bio_free_pages(pblk, bio, 0, new_bio->bi_vcnt);
+       pblk_bio_free_pages(pblk, new_bio, 0, new_bio->bi_vcnt);
+err_add_pages:
+       pr_err("pblk: failed to perform partial read\n");
        __pblk_end_io_read(pblk, rqd, false);
        return NVM_IO_ERR;
 }