MLK-22865: nandbcb: fix nandbcb dump command bug caused by MLK-22582
authorAlice Guo <alice.guo@nxp.com>
Wed, 30 Oct 2019 13:47:47 +0000 (21:47 +0800)
committerYe Li <ye.li@nxp.com>
Tue, 29 Oct 2019 08:02:47 +0000 (01:02 -0700)
In MLK-22582, write memcmp incorrectly as memcpy.

Signed-off-by: Alice Guo <alice.guo@nxp.com>
(cherry picked from commit 16a073f563a25401f1ec289db1c82dd8dab61601)

arch/arm/mach-imx/cmd_nandbcb.c

index 2bf230b..ed523d0 100644 (file)
@@ -674,7 +674,7 @@ static int do_nandbcb_dump(int argc, char * const argv[])
                        continue;
                }
                bab_block_table[i] = 0;
-               if (memcpy(dump_nand_fcb + i, &dump_fill_fcb, sizeof(dump_fill_fcb)) != 0) {
+               if (memcmp(dump_nand_fcb + i, &dump_fill_fcb, sizeof(dump_fill_fcb)) == 0) {
                        printf("mtd: found FCB%d candidate version %08x @%d:0x%x\n",
                               i, dump_nand_fcb[i].version, i, dump_fcb_off[i]);
                } else {
@@ -686,7 +686,7 @@ static int do_nandbcb_dump(int argc, char * const argv[])
                if (mtd_block_isbad(dump_mtd, (loff_t)(dump_mtd->erasesize * i)))
                        continue;
 
-               if (memcpy(dump_nand_dbbt + i, &dump_fill_dbbt, sizeof(dump_fill_dbbt)) != 0) {
+               if (memcmp(dump_nand_dbbt + i, &dump_fill_dbbt, sizeof(dump_fill_dbbt)) == 0) {
                        printf("mtd: DBBT%d found\n", i);
                        printf("mtd: Valid DBBT%d found @%d:0x%x\n", i, i, dump_dbbt_off[i]);