lkml.org 
[lkml]   [2007]   [Mar]   [9]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
DateThu, 8 Mar 2007 23:21:48 -0800
FromAmit Choudhary <>
Subject[PATCH] sound/oss/i810_audio.c: check kmalloc() return value.
Description: Check the return value of kmalloc() in function i810_open(), in file sound/oss/i810_audio.c.

Signed-off-by: Amit Choudhary <amit2030@gmail.com>

diff --git a/sound/oss/i810_audio.c b/sound/oss/i810_audio.c
index 240cc79..a415967 100644
--- a/sound/oss/i810_audio.c
+++ b/sound/oss/i810_audio.c
@@ -2580,8 +2580,13 @@ static int i810_open(struct inode *inode
 			if (card->states[i] == NULL) {
 				state = card->states[i] = (struct i810_state *)
 					kmalloc(sizeof(struct i810_state), GFP_KERNEL);
-				if (state == NULL)
+				if (state == NULL) {
+					for (--i; i >= 0; i--) {
+						kfree(card->states[i]);
+						card->states[i] = NULL;
+					}
 					return -ENOMEM;
+				}
 				memset(state, 0, sizeof(struct i810_state));
 				dmabuf = &state->dmabuf;
 				goto found_virt;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2007-03-09 08:25    [from the cache]
©2003-2008