[U-Boot] Bug in omap_gpmc.c:omap_nand_read_prefetch

Reitinger, Peter preitinger at carl-valentin.de
Mon Jun 24 13:43:54 UTC 2019


Hello,


sorry I am completely new to these kind of mailing lists, and quite probably I violate most of the rules for using this mailing list, but I have a serious bug to report and actually no time at all...


/u-boot_2019/drivers/mtd/nand/raw/omap_gpmc.c - function omap_nand_read_prefetch():


Whenever buf % 4 is neither 0 or 2 (i.e. 1 or 3), too few or too many bytes, respectively, are read before the calls to __read_prefetch_align.


Suggested fix:


original:

    /*
     * If the destination buffer is unaligned, start with reading
     * the overlap byte-wise.
     */
    head = ((uint32_t) buf) % 4;
    if (head) {
        omap_nand_read(mtd, buf, head);
        buf += head;
        len -= head;
    }


fixed:

    /*
     * If the destination buffer is unaligned, start with reading
     * the overlap byte-wise.
     */
    head = ((uint32_t) buf) % 4;
    if (head) {

        head = 4 - head; // randomly equal to head if head == 2 ;-)
        omap_nand_read(mtd, buf, head);
        buf += head;
        len -= head;
    }


Best regards

Peter Reitinger


More information about the U-Boot mailing list