summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ubi-utils/include/libmtd.h5
-rw-r--r--ubi-utils/src/libmtd.c14
2 files changed, 11 insertions, 8 deletions
diff --git a/ubi-utils/include/libmtd.h b/ubi-utils/include/libmtd.h
index d1290e0..6a93e5f 100644
--- a/ubi-utils/include/libmtd.h
+++ b/ubi-utils/include/libmtd.h
@@ -27,6 +27,9 @@
extern "C" {
#endif
+/* Maximum MTD device type string length */
+#define MTD_TYPE_MAX 64
+
/**
* struct mtd_dev_info - information about an MTD device.
* @dev_num: MTD device number
@@ -48,7 +51,7 @@ struct mtd_dev_info
int major;
int minor;
int type;
- const char *type_str;
+ const char type_str[MTD_TYPE_MAX];
long long size;
int eb_cnt;
int eb_size;
diff --git a/ubi-utils/src/libmtd.c b/ubi-utils/src/libmtd.c
index 086ee42..faa958f 100644
--- a/ubi-utils/src/libmtd.c
+++ b/ubi-utils/src/libmtd.c
@@ -108,25 +108,25 @@ int mtd_get_dev_info(const char *node, struct mtd_dev_info *mtd)
mtd->dev_num, node);
goto out_close;
case MTD_RAM:
- mtd->type_str = "RAM-based";
+ strcpy(mtd->type_str, "RAM-based");
break;
case MTD_ROM:
- mtd->type_str = "ROM";
+ strcpy(mtd->type_str, "ROM");
break;
case MTD_NORFLASH:
- mtd->type_str = "NOR";
+ strcpy(mtd->type_str, "NOR");
break;
case MTD_NANDFLASH:
- mtd->type_str = "NAND";
+ strcpy(mtd->type_str, "NAND");
break;
case MTD_DATAFLASH:
- mtd->type_str = "DataFlash";
+ strcpy(mtd->type_str, "DataFlash");
break;
case MTD_UBIVOLUME:
- mtd->type_str = "UBI-emulated MTD";
+ strcpy(mtd->type_str, "UBI-emulated MTD");
break;
default:
- mtd->type_str = "Unknown flash type";
+ strcpy(mtd->type_str, "Unknown flash type");
break;
}