aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/lightnvm/pblk-init.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/lightnvm/pblk-init.c')
-rw-r--r--drivers/lightnvm/pblk-init.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 94653b1f1300..3996e4b8fb0e 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -543,7 +543,7 @@ static int pblk_lines_init(struct pblk *pblk)
543 long nr_bad_blks, nr_meta_blks, nr_free_blks; 543 long nr_bad_blks, nr_meta_blks, nr_free_blks;
544 int bb_distance; 544 int bb_distance;
545 int i; 545 int i;
546 int ret = 0; 546 int ret;
547 547
548 lm->sec_per_line = geo->sec_per_blk * geo->nr_luns; 548 lm->sec_per_line = geo->sec_per_blk * geo->nr_luns;
549 lm->blk_per_line = geo->nr_luns; 549 lm->blk_per_line = geo->nr_luns;
@@ -638,12 +638,16 @@ add_emeta_page:
638 } 638 }
639 639
640 l_mg->bb_template = kzalloc(lm->sec_bitmap_len, GFP_KERNEL); 640 l_mg->bb_template = kzalloc(lm->sec_bitmap_len, GFP_KERNEL);
641 if (!l_mg->bb_template) 641 if (!l_mg->bb_template) {
642 ret = -ENOMEM;
642 goto fail_free_meta; 643 goto fail_free_meta;
644 }
643 645
644 l_mg->bb_aux = kzalloc(lm->sec_bitmap_len, GFP_KERNEL); 646 l_mg->bb_aux = kzalloc(lm->sec_bitmap_len, GFP_KERNEL);
645 if (!l_mg->bb_aux) 647 if (!l_mg->bb_aux) {
648 ret = -ENOMEM;
646 goto fail_free_bb_template; 649 goto fail_free_bb_template;
650 }
647 651
648 bb_distance = (geo->nr_luns) * geo->sec_per_pl; 652 bb_distance = (geo->nr_luns) * geo->sec_per_pl;
649 for (i = 0; i < lm->sec_per_line; i += bb_distance) 653 for (i = 0; i < lm->sec_per_line; i += bb_distance)
@@ -667,8 +671,10 @@ add_emeta_page:
667 671
668 pblk->lines = kcalloc(l_mg->nr_lines, sizeof(struct pblk_line), 672 pblk->lines = kcalloc(l_mg->nr_lines, sizeof(struct pblk_line),
669 GFP_KERNEL); 673 GFP_KERNEL);
670 if (!pblk->lines) 674 if (!pblk->lines) {
675 ret = -ENOMEM;
671 goto fail_free_bb_aux; 676 goto fail_free_bb_aux;
677 }
672 678
673 nr_free_blks = 0; 679 nr_free_blks = 0;
674 for (i = 0; i < l_mg->nr_lines; i++) { 680 for (i = 0; i < l_mg->nr_lines; i++) {
@@ -682,8 +688,10 @@ add_emeta_page:
682 spin_lock_init(&line->lock); 688 spin_lock_init(&line->lock);
683 689
684 nr_bad_blks = pblk_bb_line(pblk, line); 690 nr_bad_blks = pblk_bb_line(pblk, line);
685 if (nr_bad_blks < 0 || nr_bad_blks > lm->blk_per_line) 691 if (nr_bad_blks < 0 || nr_bad_blks > lm->blk_per_line) {
692 ret = -EINVAL;
686 goto fail_free_lines; 693 goto fail_free_lines;
694 }
687 695
688 line->blk_in_line = lm->blk_per_line - nr_bad_blks; 696 line->blk_in_line = lm->blk_per_line - nr_bad_blks;
689 if (line->blk_in_line < lm->min_blk_line) { 697 if (line->blk_in_line < lm->min_blk_line) {
@@ -733,7 +741,7 @@ static int pblk_writer_init(struct pblk *pblk)
733 pblk->writer_ts = kthread_create(pblk_write_ts, pblk, "pblk-writer-t"); 741 pblk->writer_ts = kthread_create(pblk_write_ts, pblk, "pblk-writer-t");
734 if (IS_ERR(pblk->writer_ts)) { 742 if (IS_ERR(pblk->writer_ts)) {
735 pr_err("pblk: could not allocate writer kthread\n"); 743 pr_err("pblk: could not allocate writer kthread\n");
736 return 1; 744 return PTR_ERR(pblk->writer_ts);
737 } 745 }
738 746
739 return 0; 747 return 0;