linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] spi: rspi: Fixes bogus received byte in qspi_transfer_in()
@ 2017-02-15 10:20 DongCV
  0 siblings, 0 replies; only message in thread
From: DongCV @ 2017-02-15 10:20 UTC (permalink / raw)
  To: broonie-DgEjT+Ai2ygdnm+yROfE0A,
	geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ,
	linux-spi-u79uwXL29TY76Z2rM5mHXA
  Cc: kuninori.morimoto.gx-zM6kxYcvzFBBDgjK7y7TUQ,
	yoshihiro.shimoda.uh-zM6kxYcvzFBBDgjK7y7TUQ,
	ryusuke.sakato.bx-zM6kxYcvzFBBDgjK7y7TUQ,
	linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA,
	nv-dung-HEF513clHfp3+QwDJ9on6Q,
	h-inayoshi-HEF513clHfp3+QwDJ9on6Q,
	cm-hiep-HEF513clHfp3+QwDJ9on6Q

In qspi_transfer_in(), when receiving the last n (or len) bytes of data,
1 bogus byte was written in the receive buffer.
This code leads to a buffer overflow.

"jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x03b40000: 0x1900 instead
 jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x03b40004: 0x000c instead"

The error message above happens when trying to mount, unmount, and remount a jffs2-formatted device.
This patch removed the bogus write to fixes: 3be09bec42a800d4
"spi: rspi: supports 32bytes buffer for DUAL and QUAD"

And here is Geert's comment:

"May I suggest the following:

    spi: rspi: Fix bogus received byte in qspi_transfer_in()

    When there are less than QSPI_BUFFER_SIZE remaining bytes to be received,
    qspi_transfer_in() writes one bogus byte in the receive buffer, possibly
    leading to a buffer overflow.

    This can be reproduced by mounting, unmounting, and remounting a
    jffs2-formatted device, causing lots of warnings like:

       jffs2: jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found
       at 0x03b40000: 0x1900 instead

    Remove the bogus write to fix this. "

Signed-off-by: DongCV <cv-dong-HEF513clHfp3+QwDJ9on6Q@public.gmane.org>

Reviewed-by: Geert Uytterhoeven <geert+renesas-gXvu3+zWzMSzQB+pC5nmwQ@public.gmane.org>
---
 drivers/spi/spi-rspi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/spi/spi-rspi.c b/drivers/spi/spi-rspi.c
index 9daf500..2ee1301 100644
--- a/drivers/spi/spi-rspi.c
+++ b/drivers/spi/spi-rspi.c
@@ -848,7 +848,6 @@ static int qspi_transfer_in(struct rspi_data *rspi, struct spi_transfer *xfer)
 			ret = rspi_pio_transfer(rspi, NULL, rx, n);
 			if (ret < 0)
 				return ret;
-			*rx++ = ret;
 		}
 		n -= len;
 	}
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-15 10:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-15 10:20 [PATCH v4] spi: rspi: Fixes bogus received byte in qspi_transfer_in() DongCV

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).