mtd_check_bad(), the function called by Yaffs code the check whether a given MTD block is bad, only returns YAFFS_FAIL (which indicates a bad block) when the MEMGETBADBLOCK ioctl returns a negative value, i.e. when an error occurs while the kernel processes the ioctl. Meanwhile, the MEMGETBADBLOCK ioctl returns 0 when a given block is good and 1 when a given block is bad. Consequently, mtd_check_bad() incorrectly reports bad blocks as good, confusing Yaffs code.
Fix by making the mtd_check_bad() function only return YAFFS_OK when a given block is good and YAFFS_FAIL in any other case (bad block or error during ioctl processing).
mtd_check_bad(), the function called by Yaffs code the check whether a given MTD block is bad, only returns YAFFS_FAIL (which indicates a bad block) when the MEMGETBADBLOCK ioctl returns a negative value, i.e. when an error occurs while the kernel processes the ioctl. Meanwhile, the MEMGETBADBLOCK ioctl returns 0 when a given block is good and 1 when a given block is bad. Consequently, mtd_check_bad() incorrectly reports bad blocks as good, confusing Yaffs code.
Fix by making the mtd_check_bad() function only return YAFFS_OK when a given block is good and YAFFS_FAIL in any other case (bad block or error during ioctl processing).