MTD: Coverity defect cleanup: MTD [1/1]
authorxianjun.liu <xianjun.liu@amlogic.com>
Mon, 16 Sep 2019 07:56:11 +0000 (15:56 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Mon, 16 Sep 2019 10:23:52 +0000 (03:23 -0700)
PD#SWPL-13991

Problem:
Out-of-bounds read in get_free_node

Solution:
fix the issue

Verify:
AXG400

Change-Id: I6e41caf3b3118d524218d6023fb51df692865cba
Signed-off-by: xianjun.liu <xianjun.liu@amlogic.com>
drivers/amlogic/mtd/rsv_manage.c

index 7b6d2d8..d49a7ce 100644 (file)
@@ -44,7 +44,7 @@ static struct free_node_t *get_free_node(struct mtd_info *mtd)
 
        index = find_first_zero_bit((void *)&aml_chip->freeNodeBitmask,
                                    RESERVED_BLOCK_NUM);
-       if (index > RESERVED_BLOCK_NUM) {
+       if (index >= RESERVED_BLOCK_NUM) {
                pr_info("%s %d: index is greater than max! error",
                        __func__, __LINE__);
                return NULL;