lightnvm: pblk: check for chunk size before allocating it
authorJavier González <javier@javigon.com>
Fri, 1 Jun 2018 13:04:23 +0000 (15:04 +0200)
committerJens Axboe <axboe@kernel.dk>
Fri, 1 Jun 2018 13:43:53 +0000 (07:43 -0600)
Do the check for the chunk state after making sure that the chunk type
is supported.

Fixes: 32ef9412c114 ("lightnvm: pblk: implement get log report chunk")
Signed-off-by: Javier González <javier@cnexlabs.com>
Signed-off-by: Matias Bjørling <mb@lightnvm.io>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/lightnvm/pblk-init.c

index 1e1771864da0fe436296adfc0d02dc6744b1e732..81c103b341bd618564430b7cca1c00ae5a01711e 100644 (file)
@@ -751,14 +751,14 @@ static int pblk_setup_line_meta_20(struct pblk *pblk, struct pblk_line *line,
                chunk->cnlb = chunk_meta->cnlb;
                chunk->wp = chunk_meta->wp;
 
-               if (!(chunk->state & NVM_CHK_ST_OFFLINE))
-                       continue;
-
                if (chunk->type & NVM_CHK_TP_SZ_SPEC) {
                        WARN_ONCE(1, "pblk: custom-sized chunks unsupported\n");
                        continue;
                }
 
+               if (!(chunk->state & NVM_CHK_ST_OFFLINE))
+                       continue;
+
                set_bit(pos, line->blk_bitmap);
                nr_bad_chks++;
        }