From: Matias Bjørling Date: Tue, 29 Dec 2015 13:37:56 +0000 (+0100) Subject: lightnvm: wrong offset in bad blk lun calculation X-Git-Tag: firefly_0821_release~176^2~506^2 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=c3293a9ac2a4f9160b85b5e986a8e0c54986e7f7;p=firefly-linux-kernel-4.4.55.git lightnvm: wrong offset in bad blk lun calculation dev->nr_luns reports the total number of luns available in a device while dev->luns_per_chnl is the number of luns per channel. When multiple channels are available, the offset is calculated from a channel and lun id into a linear array. As it multiplies with the total number of luns, we go out of bound when channel id > 0 and causes the kernel to panic when we read a protected kernel memory area. Signed-off-by: Matias Bjørling Signed-off-by: Jens Axboe --- diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c index f434e89e1c7a..a54b339951a3 100644 --- a/drivers/lightnvm/gennvm.c +++ b/drivers/lightnvm/gennvm.c @@ -75,7 +75,7 @@ static int gennvm_block_bb(struct ppa_addr ppa, int nr_blocks, u8 *blks, struct nvm_block *blk; int i; - lun = &gn->luns[(dev->nr_luns * ppa.g.ch) + ppa.g.lun]; + lun = &gn->luns[(dev->luns_per_chnl * ppa.g.ch) + ppa.g.lun]; for (i = 0; i < nr_blocks; i++) { if (blks[i] == 0)