Skip to contentSkip to conversation

mtd: onenand: samsung: Fix iomem access with regular memcpy

RFT Applied Krzysztof Kozlowski 2 participants 2 messages Jan 3, 2020 – Jan 9, 2020

Subsystems (4)
lore
Share & tools
lore

Krzysztof Kozlowski

author maintainer
#0 lore raw

The __iomem memory should be copied with memcpy_fromio. This fixes Sparse warnings like:

drivers/mtd/nand/onenand/samsung_mtd.c:678:40: warning: incorrect type in argument 2 (different address spaces)
drivers/mtd/nand/onenand/samsung_mtd.c:678:40: expected void const *from
drivers/mtd/nand/onenand/samsung_mtd.c:678:40: got void [noderef] <asn:2> *[assigned] p
drivers/mtd/nand/onenand/samsung_mtd.c:679:19: warning: incorrect type in assignment (different address spaces)
drivers/mtd/nand/onenand/samsung_mtd.c:679:19: expected void [noderef] <asn:2> *[assigned] p
drivers/mtd/nand/onenand/samsung_mtd.c:679:19: got unsigned char *

---

Not tested

---
 drivers/mtd/nand/onenand/samsung_mtd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/nand/onenand/samsung_mtd.c +4 -4
index 4a78c0aed6dd..01899f8bdfa7 100644
@@ -675,12 +675,12 @@ static int s5pc110_read_bufferram(struct mtd_info *mtd, int area,
 normal:
 	if (count != mtd->writesize) {
 		/* Copy the bufferram to memory to prevent unaligned access */
-		memcpy(this->page_buf, p, mtd->writesize);
-		p = this->page_buf + offset;
+		memcpy_fromio(this->page_buf, p, mtd->writesize);
+		memcpy(buffer, this->page_buf + offset, count);
+	} else {
+		memcpy_fromio(buffer, p, count);
 	}
 
-	memcpy(buffer, p, count);
-
 	return 0;
 }
 
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw
Quoted 10 lines · Krzysztof Kozlowski

The __iomem memory should be copied with memcpy_fromio. This fixes Sparse warnings like:

drivers/mtd/nand/onenand/samsung_mtd.c:678:40: warning: incorrect type in argument 2 (different address spaces)
drivers/mtd/nand/onenand/samsung_mtd.c:678:40: expected void const *from
drivers/mtd/nand/onenand/samsung_mtd.c:678:40: got void [noderef] <asn:2> *[assigned] p
drivers/mtd/nand/onenand/samsung_mtd.c:679:19: warning: incorrect type in assignment (different address spaces)
drivers/mtd/nand/onenand/samsung_mtd.c:679:19: expected void [noderef] <asn:2> *[assigned] p
drivers/mtd/nand/onenand/samsung_mtd.c:679:19: got unsigned char *

Quoted 2 lines

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks.

Miquel

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel