Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: onenand_base: onenand_verify bugfix for writepage non-aligned address

In onenand_verify function the address can be writepage non-aligned.
When a page is read for comparing the right offset should be used
for "this->verify_buf" to get the right matching with compared
"buf" buffer.

Signed-off-by: Roman Tereshonkov <roman.tereshonkov@nokia.com>
Signed-off-by: Adrian Hunter <adrian.hunter@nokia.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>

authored by

Roman Tereshonkov and committed by
David Woodhouse
e6da8568 b085058f

+5 -5
+5 -5
drivers/mtd/onenand/onenand_base.c
··· 1648 1648 int ret = 0; 1649 1649 int thislen, column; 1650 1650 1651 + column = addr & (this->writesize - 1); 1652 + 1651 1653 while (len != 0) { 1652 - thislen = min_t(int, this->writesize, len); 1653 - column = addr & (this->writesize - 1); 1654 - if (column + thislen > this->writesize) 1655 - thislen = this->writesize - column; 1654 + thislen = min_t(int, this->writesize - column, len); 1656 1655 1657 1656 this->command(mtd, ONENAND_CMD_READ, addr, this->writesize); 1658 1657 ··· 1665 1666 1666 1667 this->read_bufferram(mtd, ONENAND_DATARAM, this->verify_buf, 0, mtd->writesize); 1667 1668 1668 - if (memcmp(buf, this->verify_buf, thislen)) 1669 + if (memcmp(buf, this->verify_buf + column, thislen)) 1669 1670 return -EBADMSG; 1670 1671 1671 1672 len -= thislen; 1672 1673 buf += thislen; 1673 1674 addr += thislen; 1675 + column = 0; 1674 1676 } 1675 1677 1676 1678 return 0;