* [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
* Re: [PATCH 2.6.19-rc2] sound/oss/i810_audio.c: check kmalloc() return value.
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
0 siblings, 0 replies; 2+ messages in thread
From: Pekka Enberg @ 2006-10-23 6:35 UTC (permalink / raw)
To: Amit Choudhary; +Cc: Linux Kernel
On 10/23/06, Amit Choudhary <amit2030@gmail.com> wrote:
> @@ -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;
Looks wrong to me. We only allocate memory once in the loop (hint:
goto found_virt at the bottom here).
^ permalink raw reply [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