From 1a214ee6e3ef540013e5978504eaa831efc5921c Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Tue, 10 Aug 2004 17:25:01 +0100 Subject: Fix use-after-free bug in MTD partitioning code. Define callback wrapper function mtd_erase_callback() to handle partition offsets during the callback, rather than attempting to fix them up in the freed erase_info structure after the callback has already happened. --- include/linux/mtd/mtd.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index fd7b15d077b3..b3d134392b31 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h @@ -1,5 +1,5 @@ /* - * $Id: mtd.h,v 1.54 2004/07/15 01:13:12 dwmw2 Exp $ + * $Id: mtd.h,v 1.56 2004/08/09 18:46:04 dmarlin Exp $ * * Copyright (C) 1999-2003 David Woodhouse et al. * @@ -19,6 +19,7 @@ #include #include +#include #include #define MTD_CHAR_MAJOR 90 @@ -192,6 +193,17 @@ int default_mtd_readv(struct mtd_info *mtd, struct kvec *vecs, #define MTD_WRITEOOB(mtd, args...) (*(mtd->write_oob))(mtd, args) #define MTD_SYNC(mtd) do { if (mtd->sync) (*(mtd->sync))(mtd); } while (0) + +#ifdef CONFIG_MTD_PARTITIONS +void mtd_erase_callback(struct erase_info *instr); +#else +static inline void mtd_erase_callback(struct erase_info *instr) +{ + if (instr->callback) + instr->callback(instr); +} +#endif + /* * Debugging macro and defines */ -- cgit v1.2.3 From be3a60978fdb757ff8fab31b8c43a09a156b092c Mon Sep 17 00:00:00 2001 From: Josh Boyer Date: Tue, 10 Aug 2004 18:13:52 +0100 Subject: Restore physmap configure-time settings according to user requests. Patch from Jun Sun. Signed-Off-By: David Woodhouse --- drivers/mtd/maps/Kconfig | 15 +++++++++++---- drivers/mtd/maps/physmap.c | 9 +++++++-- include/linux/mtd/physmap.h | 6 +++--- 3 files changed, 21 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig index b1ad6567b735..cdc5bbd166a3 100644 --- a/drivers/mtd/maps/Kconfig +++ b/drivers/mtd/maps/Kconfig @@ -1,5 +1,5 @@ # drivers/mtd/maps/Kconfig -# $Id: Kconfig,v 1.29 2004/07/15 15:29:17 dwmw2 Exp $ +# $Id: Kconfig,v 1.30 2004/07/21 00:16:14 jwboyer Exp $ menu "Mapping drivers for chip access" depends on MTD!=n @@ -19,7 +19,8 @@ config MTD_PHYSMAP command set driver code to communicate with flash chips which are mapped physically into the CPU's memory. You will need to configure the physical address and size of the flash chips on - your particular board as well as the bus width. + your particular board as well as the bus width, either statically + with config options or at run-time. config MTD_PHYSMAP_START hex "Physical start address of flash mapping" @@ -30,6 +31,8 @@ config MTD_PHYSMAP_START are mapped on your particular target board. Refer to the memory map which should hopefully be in the documentation for your board. + Ignore this option if you use run-time physmap configuration + (i.e., run-time calling physmap_configure()). config MTD_PHYSMAP_LEN hex "Physical length of flash mapping" @@ -42,9 +45,11 @@ config MTD_PHYSMAP_LEN than the total amount of flash present. Refer to the memory map which should hopefully be in the documentation for your board. + Ignore this option if you use run-time physmap configuration + (i.e., run-time calling physmap_configure()). -config MTD_PHYSMAP_BUSWIDTH - int "Bus width in octets" +config MTD_PHYSMAP_BANKWIDTH + int "Bank width in octets" depends on MTD_PHYSMAP default "2" help @@ -52,6 +57,8 @@ config MTD_PHYSMAP_BUSWIDTH in octets. For example, if you have a data bus width of 32 bits, you would set the bus width octect value to 4. This is used internally by the CFI drivers. + Ignore this option if you use run-time physmap configuration + (i.e., run-time calling physmap_configure()). config MTD_SUN_UFLASH tristate "Sun Microsystems userflash support" diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c index 8dfd0b233616..5822ba99c195 100644 --- a/drivers/mtd/maps/physmap.c +++ b/drivers/mtd/maps/physmap.c @@ -1,5 +1,5 @@ /* - * $Id: physmap.c,v 1.33 2004/07/12 14:37:24 dwmw2 Exp $ + * $Id: physmap.c,v 1.34 2004/07/21 00:16:14 jwboyer Exp $ * * Normal mappings of chips in physical memory * @@ -22,7 +22,12 @@ static struct mtd_info *mymtd; -struct map_info physmap_map = {.name = "phys_mapped_flash"}; +struct map_info physmap_map = { + .name = "phys_mapped_flash", + .phys = CONFIG_MTD_PHYSMAP_START, + .size = CONFIG_MTD_PHYSMAP_LEN, + .bankwidth = CONFIG_MTD_PHYSMAP_BANKWIDTH, +}; #ifdef CONFIG_MTD_PARTITIONS static struct mtd_partition *mtd_parts; diff --git a/include/linux/mtd/physmap.h b/include/linux/mtd/physmap.h index d522d43d410d..05aa4970677f 100644 --- a/include/linux/mtd/physmap.h +++ b/include/linux/mtd/physmap.h @@ -2,7 +2,7 @@ * For boards with physically mapped flash and using * drivers/mtd/maps/physmap.c mapping driver. * - * $Id: physmap.h,v 1.2 2004/07/14 17:48:46 dwmw2 Exp $ + * $Id: physmap.h,v 1.3 2004/07/21 00:16:15 jwboyer Exp $ * * Copyright (C) 2003 MontaVista Software Inc. * Author: Jun Sun, jsun@mvista.com or jsun@junsun.net @@ -33,11 +33,11 @@ extern struct map_info physmap_map; /* * Board needs to specify the exact mapping during their setup time. */ -static inline void physmap_configure(unsigned long addr, unsigned long size, int buswidth, void (*set_vpp)(struct map_info *, int) ) +static inline void physmap_configure(unsigned long addr, unsigned long size, int bankwidth, void (*set_vpp)(struct map_info *, int) ) { physmap_map.phys = addr; physmap_map.size = size; - physmap_map.buswidth = buswidth; + physmap_map.bankwidth = bankwidth; physmap_map.set_vpp = set_vpp; } -- cgit v1.2.3