summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-09 22:24:52 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-09-09 22:24:52 +0000
commit1a7287a8a4eeca7fc2a677b983b25877350d1439 (patch)
tree6ace3fe5230b5ea355c054a72f400ee026710580
parent0f24fe7e11df5bd1551e1f89d9cb6d7a15243ebb (diff)
downloadnuttx-1a7287a8a4eeca7fc2a677b983b25877350d1439.tar.gz
nuttx-1a7287a8a4eeca7fc2a677b983b25877350d1439.tar.bz2
nuttx-1a7287a8a4eeca7fc2a677b983b25877350d1439.zip
Some error handling bugs noted by Ronen Vainish
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5122 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/ChangeLog5
-rw-r--r--nuttx/drivers/mmcsd/mmcsd_sdio.c4
-rw-r--r--nuttx/fs/fs_fdopen.c2
3 files changed, 9 insertions, 2 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 6f899a7ab..3ab4302ab 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -3300,4 +3300,9 @@
but tested has been deferred until I get the right tools.
* arch/arc/include/stm32/chip.h and arch/arm/src/stm32/chip.h:
Add support for the STM32F103VET6.
+ * fs/fs_fdopen.c: Bad check for failure to allocate memory. (Noted
+ by Ronen Vainish).
+ * drivers/mmcsd/mmcsd_sdio.c: If the MMC/SD driver were ever
+ uninitialized then there would be a double release of memory
+ (Noted by Ronen Vainish).
diff --git a/nuttx/drivers/mmcsd/mmcsd_sdio.c b/nuttx/drivers/mmcsd/mmcsd_sdio.c
index 90c73261a..d0bc6659c 100644
--- a/nuttx/drivers/mmcsd/mmcsd_sdio.c
+++ b/nuttx/drivers/mmcsd/mmcsd_sdio.c
@@ -3171,7 +3171,9 @@ errout_with_buffers:
rwb_uninitialize(&priv->rwbuffer);
errout_with_hwinit:
#endif
- mmcsd_hwuninitialize(priv);
+ mmcsd_hwuninitialize(priv); /* This will free the private data structure */
+ return ret;
+
errout_with_alloc:
kfree(priv);
return ret;
diff --git a/nuttx/fs/fs_fdopen.c b/nuttx/fs/fs_fdopen.c
index ee6440bf5..fd6aa88a8 100644
--- a/nuttx/fs/fs_fdopen.c
+++ b/nuttx/fs/fs_fdopen.c
@@ -220,7 +220,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR _TCB *tcb)
/* Allocate the IO buffer */
stream->fs_bufstart = kmalloc(CONFIG_STDIO_BUFFER_SIZE);
- if (!stream)
+ if (!stream->fs_bufstart)
{
err = ENOMEM;
goto errout_with_sem;