nand: fix the free-node leak in rsv manager [1/1]
authorYi Zeng <yi.zeng@amlogic.com>
Mon, 10 Dec 2018 07:57:18 +0000 (15:57 +0800)
committerLuan Yuan <luan.yuan@amlogic.com>
Mon, 17 Dec 2018 09:19:38 +0000 (17:19 +0800)
PD#SWPL-2776

Problem:
did not release the free node of rsv information

Solution:
release free node and set bit mask in right way

Verify:
S400

Change-Id: I781f2374b91ca1e7cd1a66e75fc554318737c377
Signed-off-by: Yi Zeng <yi.zeng@amlogic.com>
drivers/amlogic/mtd/rsv_manage.c

index 343a7f5..7969936 100644 (file)
@@ -42,16 +42,14 @@ static struct free_node_t *get_free_node(struct mtd_info *mtd)
        pr_info("%s %d: bitmap=%llx\n", __func__, __LINE__,
                aml_chip->freeNodeBitmask);
 
-       index = find_first_zero_bit((void *)&aml_chip->freeNodeBitmask, 64);
+       index = find_first_zero_bit((void *)&aml_chip->freeNodeBitmask,
+                                   RESERVED_BLOCK_NUM);
        if (index > RESERVED_BLOCK_NUM) {
                pr_info("%s %d: index is greater than max! error",
                        __func__, __LINE__);
                return NULL;
        }
-       if (test_and_set_bit(index, (void *)&aml_chip->freeNodeBitmask)) {
-               pr_info("%s %d: error!!!\n", __func__, __LINE__);
-               return NULL;
-       }
+       WARN_ON(test_and_set_bit(index, (void *)&aml_chip->freeNodeBitmask));
 
        pr_info("%s %d: bitmap=%llx\n", __func__, __LINE__,
                aml_chip->freeNodeBitmask);
@@ -73,9 +71,8 @@ static void release_free_node(struct mtd_info *mtd,
                pr_info("%s %d: index=%d is greater than max! error",
                        __func__, __LINE__, free_node->index);
 
-       if (test_and_clear_bit(free_node->index,
-               (void *)&aml_chip->freeNodeBitmask))
-               return;
+       WARN_ON(!test_and_clear_bit(free_node->index,
+                               (void *)&aml_chip->freeNodeBitmask));
 
        /*memset zero to protect from dead-loop*/
        memset(free_node, 0, sizeof(struct free_node_t));