Skip to content

Commit

Permalink
lightnvm: proper error handling for pblk_bio_add_pages
Browse files Browse the repository at this point in the history
Currently in case of error caused by bio_pc_add_page in
pblk_bio_add_pages two issues occur when calling from
pblk_rb_read_to_bio(). First one is in pblk_bio_free_pages, since we
are trying to free pages not allocated from our mempool. Second one
is the warn from dma_pool_free, that we are trying to free NULL
pointer dma.

This commit fix both issues.

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>
  • Loading branch information
Igor Konopko authored and Jens Axboe committed Jun 1, 2018
1 parent 6cf17a2 commit f142ac0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/lightnvm/pblk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ void pblk_free_rqd(struct pblk *pblk, struct nvm_rq *rqd, int type)
return;
}

nvm_dev_dma_free(dev->parent, rqd->meta_list, rqd->dma_meta_list);
if (rqd->meta_list)
nvm_dev_dma_free(dev->parent, rqd->meta_list,
rqd->dma_meta_list);
mempool_free(rqd, pool);
}

Expand Down Expand Up @@ -316,7 +318,7 @@ int pblk_bio_add_pages(struct pblk *pblk, struct bio *bio, gfp_t flags,

return 0;
err:
pblk_bio_free_pages(pblk, bio, 0, i - 1);
pblk_bio_free_pages(pblk, bio, (bio->bi_vcnt - i), i);
return -1;
}

Expand Down

0 comments on commit f142ac0

Please sign in to comment.