fs: ubifs: Do not use a buffer allocated from malloc function
authorDonggeun Kim <dg77.kim@samsung.com>
Wed, 6 Oct 2010 09:19:40 +0000 (18:19 +0900)
committerDonggeun Kim <dg77.kim@samsung.com>
Wed, 6 Oct 2010 09:19:40 +0000 (18:19 +0900)
Signed-off-by: Donggeun Kim <dg77.kim@samsung.com>
common/cmd_usbd.c
fs/ubifs/mkfs.ubifs.c
include/configs/s5pc1xx_universal.h
include/configs/s5pc210_universal.h
include/mkfs.ubifs.h

index 9c4335f..2d7eeac 100644 (file)
@@ -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) {
index 2aff5f5..1bb55ca 100644 (file)
@@ -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);
index 60143d2..56b9adc 100644 (file)
@@ -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 */
 
 /*
index 1323ebe..45fdbc1 100644 (file)
@@ -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 */
 
 /*
index a4d10c3..c672dce 100644 (file)
@@ -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