mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 11:26:12 +08:00
mtd: fix some unallocated and NULL pointer issues. rwb->wrflush and rwb->wrmaxblocks in rwbuffer could get unallocated values from ftl_initialize() in some configurations. Also fixes related assert:
up_assert: Assertion failed at file:rwbuffer.c line: 643 that can happen with the following configuration: CONFIG_FTL_WRITEBUFFER=y CONFIG_DRVR_WRITEBUFFER=y # CONFIG_FS_WRITABLE is not set These problems are caused by CONFIG variable differences between the buffer layers. TODO: This is not a perfect solution. readahead support has similar issues.
This commit is contained in:
committed by
Gregory Nutt
parent
58a0b09b82
commit
0f7210b0ae
+7
-1
@@ -528,7 +528,7 @@ int ftl_initialize(int minor, FAR struct mtd_dev_s *mtd)
|
||||
|
||||
/* Allocate a FTL device structure */
|
||||
|
||||
dev = (struct ftl_struct_s *)kmm_malloc(sizeof(struct ftl_struct_s));
|
||||
dev = (struct ftl_struct_s *)kmm_zalloc(sizeof(struct ftl_struct_s));
|
||||
if (dev)
|
||||
{
|
||||
/* Initialize the FTL device structure */
|
||||
@@ -586,6 +586,9 @@ int ftl_initialize(int minor, FAR struct mtd_dev_s *mtd)
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: rwb_initialize failed: %d\n", ret);
|
||||
#ifdef CONFIG_FS_WRITABLE
|
||||
kmm_free(dev->eblock);
|
||||
#endif
|
||||
kmm_free(dev);
|
||||
return ret;
|
||||
}
|
||||
@@ -601,6 +604,9 @@ int ftl_initialize(int minor, FAR struct mtd_dev_s *mtd)
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: register_blockdriver failed: %d\n", -ret);
|
||||
#ifdef CONFIG_FS_WRITABLE
|
||||
kmm_free(dev->eblock);
|
||||
#endif
|
||||
kmm_free(dev);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user