linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Francois Romieu <romieu@fr.zoreil.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org, torvalds@osdl.org
Subject: [PATCH] Fix error path in AD1889 driver
Date: Sat, 12 Jul 2003 00:57:16 +0200	[thread overview]
Message-ID: <20030712005716.C25528@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <20030712004501.B25528@electric-eye.fr.zoreil.com>; from romieu@fr.zoreil.com on Sat, Jul 12, 2003 at 12:45:01AM +0200

Memory leak fix: the allocated areas weren't referenced any more once the
original error path returned.


 sound/oss/ad1889.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff -puN sound/oss/ad1889.c~janitor-error-path-ad1889 sound/oss/ad1889.c
--- linux-2.5.75-20030711_0808/sound/oss/ad1889.c~janitor-error-path-ad1889	Sat Jul 12 00:40:29 2003
+++ linux-2.5.75-20030711_0808-fr/sound/oss/ad1889.c	Sat Jul 12 00:40:29 2003
@@ -236,16 +236,24 @@ static ad1889_dev_t *ad1889_alloc_dev(st
 
 	for (i = 0; i < AD_MAX_STATES; i++) {
 		dmabuf = &dev->state[i].dmabuf;
-		if ((dmabuf->rawbuf = kmalloc(DMA_SIZE, GFP_KERNEL|GFP_DMA)) == NULL)
-			return NULL;
+		dmabuf->rawbuf = kmalloc(DMA_SIZE, GFP_KERNEL|GFP_DMA);
+		if (!dmabuf->rawbuf)
+			goto err_free_dmabuf;
 		dmabuf->rawbuf_size = DMA_SIZE;
 		dmabuf->dma_handle = 0;
 		dmabuf->rd_ptr = dmabuf->wr_ptr = dmabuf->dma_len = 0UL;
 		dmabuf->ready = 0;
 		dmabuf->rate = 44100;
 	}
-
+out:
 	return dev;
+
+err_free_dmabuf:
+	while (--i >= 0)
+		kfree(dev->state[i].dmabuf.rawbuf);
+	kfree(dev);
+	dev = NULL;
+	goto out;
 }
 
 static void ad1889_free_dev(ad1889_dev_t *dev)

_

  reply	other threads:[~2003-07-11 22:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-11 18:21 PATCH: Merge AD1889 driver from 2.4 Alan Cox
2003-07-11 22:45 ` [PATCH] " Francois Romieu
2003-07-11 22:57   ` Francois Romieu [this message]
2003-07-13  8:11     ` [PATCH] Fix error path in AD1889 driver Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030712005716.C25528@electric-eye.fr.zoreil.com \
    --to=romieu@fr.zoreil.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).