From 2fc301cc224859decb54a37e112cd1a516bf7a49 Mon Sep 17 00:00:00 2001 From: Donggeun Kim Date: Wed, 6 Oct 2010 18:19:40 +0900 Subject: [PATCH] fs: ubifs: Do not use a buffer allocated from malloc function Signed-off-by: Donggeun Kim --- common/cmd_usbd.c | 6 ++---- fs/ubifs/mkfs.ubifs.c | 10 ++++------ include/configs/s5pc1xx_universal.h | 2 +- include/configs/s5pc210_universal.h | 2 +- include/mkfs.ubifs.h | 2 +- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/common/cmd_usbd.c b/common/cmd_usbd.c index 9c4335f..2d7eeac 100644 --- a/common/cmd_usbd.c +++ b/common/cmd_usbd.c @@ -1098,7 +1098,7 @@ static int process_data(struct usbd_ops *usbd) printf("CSA Clear will be skipped temporary\n"); #ifdef CONFIG_UBIFS_MK - void *dest_addr; + void *dest_addr = (void *) down_ram_addr + 0xc00000; void *src_addr = (void *) down_ram_addr; int leb_size, max_leb_cnt, mkfs_min_io_size; unsigned long ubifs_dest_size, ubi_dest_size; @@ -1112,7 +1112,7 @@ static int process_data(struct usbd_ops *usbd) max_leb_cnt = 4096; #endif printf("Start making ubifs\n"); - ret = mkfs(src_addr, len, &dest_addr, &ubifs_dest_size, + ret = mkfs(src_addr, len, dest_addr, &ubifs_dest_size, mkfs_min_io_size, leb_size, max_leb_cnt); if (ret) { printf("Error : making ubifs failed\n"); @@ -1146,8 +1146,6 @@ static int process_data(struct usbd_ops *usbd) printf("Complete ubinizing\n"); len = (unsigned int) ubi_dest_size; - - free(dest_addr); #endif /* Write : arg (0 Modem) / (1 CSA) */ if (!arg) { diff --git a/fs/ubifs/mkfs.ubifs.c b/fs/ubifs/mkfs.ubifs.c index 2aff5f5..1bb55ca 100644 --- a/fs/ubifs/mkfs.ubifs.c +++ b/fs/ubifs/mkfs.ubifs.c @@ -1602,10 +1602,6 @@ static int init(void) if (err) return err; - modem_buf = malloc(MODEM_IMAGE_SIZE); - if (!modem_buf) - return err_msg("out of memory"); - return 0; } @@ -1632,7 +1628,7 @@ static void deinit(void) * incremental updates to the output file. */ int mkfs(void *src_addr, unsigned long src_size, - void **dest_addr, unsigned long *dest_size, + void *dest_addr, unsigned long *dest_size, int min_io_size, int leb_size, int max_leb_cnt) { int err = 0; @@ -1642,6 +1638,9 @@ int mkfs(void *src_addr, unsigned long src_size, char *name = "modem.bin"; unsigned long root_dir_size = UBIFS_INO_NODE_SZ; + modem_buf = dest_addr; + memset(modem_buf, 0, MODEM_IMAGE_SIZE); + err = set_options(min_io_size, leb_size, max_leb_cnt); if (err) return err; @@ -1706,7 +1705,6 @@ int mkfs(void *src_addr, unsigned long src_size, err = write_orphan_area(); - *dest_addr = modem_buf; *dest_size = (unsigned long) c->leb_cnt * c->leb_size; printf("ubifs image offset : 0x%x\n", (unsigned int) dest_addr); diff --git a/include/configs/s5pc1xx_universal.h b/include/configs/s5pc1xx_universal.h index 60143d2..56b9adc 100644 --- a/include/configs/s5pc1xx_universal.h +++ b/include/configs/s5pc1xx_universal.h @@ -72,7 +72,7 @@ /* * Size of malloc() pool */ -#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 15 * 1024 * 1024) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 1024 * 1024) #define CONFIG_SYS_GBL_DATA_SIZE 128 /* size in bytes for initial data */ /* diff --git a/include/configs/s5pc210_universal.h b/include/configs/s5pc210_universal.h index 1323ebe..45fdbc1 100644 --- a/include/configs/s5pc210_universal.h +++ b/include/configs/s5pc210_universal.h @@ -67,7 +67,7 @@ /* * Size of malloc() pool */ -#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 15 * 1024 * 1024) +#define CONFIG_SYS_MALLOC_LEN (CONFIG_ENV_SIZE + 1024 * 1024) #define CONFIG_SYS_GBL_DATA_SIZE 128 /* size in bytes for initial data */ /* diff --git a/include/mkfs.ubifs.h b/include/mkfs.ubifs.h index a4d10c3..c672dce 100644 --- a/include/mkfs.ubifs.h +++ b/include/mkfs.ubifs.h @@ -2,6 +2,6 @@ #define __MKFS_UBIFS_FUNC_H__ extern int mkfs(void *src_addr, unsigned long src_size, - void **dest_addr, unsigned long *dest_size, + void *dest_addr, unsigned long *dest_size, int min_io_size, int leb_size, int max_leb_cnt); #endif -- 2.7.4