Skip to content

Commit 3cff177

Browse files
shivamurthyshastrimiquelraynal
authored andcommitted
mtd: map_ram: prevent use of point and unpoint when NO_XIP is set
When the DT property no-unaligned-direct-access is set, map->phys is set to NO_XIP. With this property set, the flash should not be exposed directly to MTD users, since it cannot be mapped. map_ram() exposes the flash direct access unconditionally which leads to access errors (when the bus width does not match the RAM width). Therefore do not set point and unpoint when NO_XIP is set. Signed-off-by: Shivamurthy Shastri <[email protected]> Reviewed-by: Benedikt Spranger <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://lore.kernel.org/linux-mtd/[email protected]
1 parent 28a05da commit 3cff177

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/mtd/chips/map_ram.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,16 @@ static struct mtd_info *map_ram_probe(struct map_info *map)
7070
mtd->_read = mapram_read;
7171
mtd->_write = mapram_write;
7272
mtd->_panic_write = mapram_write;
73-
mtd->_point = mapram_point;
7473
mtd->_sync = mapram_nop;
75-
mtd->_unpoint = mapram_unpoint;
7674
mtd->flags = MTD_CAP_RAM;
7775
mtd->writesize = 1;
7876

77+
/* Disable direct access when NO_XIP is set */
78+
if (map->phys != NO_XIP) {
79+
mtd->_point = mapram_point;
80+
mtd->_unpoint = mapram_unpoint;
81+
}
82+
7983
mtd->erasesize = PAGE_SIZE;
8084
while(mtd->size & (mtd->erasesize - 1))
8185
mtd->erasesize >>= 1;

0 commit comments

Comments
 (0)