Skip to contentSkip to conversation

Fix silent truncations in the SPI NOR driver

PATCH In review Sergei Shtylyov 2 participants 4 messages Oct 30, 2019 – Nov 2, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Fix silent truncations in the SPI NOR driver

Hello!

Here's a set of 2 patches against the 'mtd/fixes' branch of the MTD 'linux.git' repo. The SPI NOR driver assigns th result of a function returning 'ssize_t' to the *int* variable in a couple of places, while 'ssize_t' is a 64-bit type and *int* is a 32-bit type on the 64-bit machines. The silent truncation that happens there isn't really valid, so we have to fix up the variable's type...

[1/2] mtd: spi-nor: fix silent truncation in spi_nor_read() [2/2] mtd: spi-nor: fix silent truncation in spi_nor_read_raw()

MBR, Sergei

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#1 lore raw

PATCH v2 1/2 mtd: spi-nor: fix silent truncation in spi_nor_read()

spi_nor_read() assigns the result of 'ssize_t spi_nor_read_data()' to the 'int ret' variable, while 'ssize_t' is a 64-bit type and *int* is a 32-bit type on the 64-bit machines. This silent truncation isn't really valid, so fix up the variable's type.

Fixes 59451e1233bd ("mtd: spi-nor: change return value of read/write")

---
Changes in version 2:
- cleaned up the patch description.

 drivers/mtd/spi-nor/spi-nor.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/spi-nor.c +1 -1
Index: linux/drivers/mtd/spi-nor/spi-nor.c
===================================================================
@@ -2544,7 +2544,7 @@ static int spi_nor_read(struct mtd_info
 			size_t *retlen, u_char *buf)
 {
 	struct spi_nor *nor = mtd_to_spi_nor(mtd);
-	int ret;
+	ssize_t ret;
 
 	dev_dbg(nor->dev, "from 0x%08x, len %zd\n", (u32)from, len);
 

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#2 lore raw

PATCH v2 2/2 mtd: spi-nor: fix silent truncation in spi_nor_read_raw()

In reply to Sergei Shtylyov

spi_nor_read_raw() assigns the result of 'ssize_t spi_nor_read_data()' to the 'int ret' variable, while 'ssize_t' is a 64-bit type and *int* is a 32-bit type on the 64-bit machines. This silent truncation isn't really valid, so fix up the variable's type.

Fixes f384b352cbf0 ("mtd: spi-nor: parse Serial Flash Discoverable Parameters (SFDP) tables")

---
Changes in version 2:
- new patch.

 drivers/mtd/spi-nor/spi-nor.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/spi-nor.c +1 -1
Index: linux/drivers/mtd/spi-nor/spi-nor.c
===================================================================
@@ -2865,7 +2865,7 @@ static int spi_nor_hwcaps_pp2cmd(u32 hwc
  */
 static int spi_nor_read_raw(struct spi_nor *nor, u32 addr, size_t len, u8 *buf)
 {
-	int ret;
+	ssize_t ret;
 
 	while (len) {
 		ret = spi_nor_read_data(nor, addr, len, buf);

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

#3 lore raw
In reply to Sergei Shtylyov
Quoted 5 lines · Sergei Shtylyov

External E-Mail

Hello!

Quoted 9 lines

Here's a set of 2 patches against the 'mtd/fixes' branch of the MTD 'linux.git' repo. The SPI NOR driver assigns th result of a function returning 'ssize_t' to the *int* variable in a couple of places, while 'ssize_t' is a 64-bit type and *int* is a 32-bit type on the 64-bit machines. The silent truncation that happens there isn't really valid, so we have to fix up the variable's type...

[1/2] mtd: spi-nor: fix silent truncation in spi_nor_read() [2/2] mtd: spi-nor: fix silent truncation in spi_nor_read_raw()

Both applied to spi-nor/next. Thanks.
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/