public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.19-rc2] sound/oss/i810_audio.c: check kmalloc() return value.
@ 2006-10-23  5:17 Amit Choudhary
  2006-10-23  6:35 ` Pekka Enberg
  0 siblings, 1 reply; 2+ messages in thread
From: Amit Choudhary @ 2006-10-23  5:17 UTC (permalink / raw)
  To: Linux Kernel

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;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-10-23  6:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-23  5:17 [PATCH 2.6.19-rc2] sound/oss/i810_audio.c: check kmalloc() return value Amit Choudhary
2006-10-23  6:35 ` Pekka Enberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox