Skip to contentSkip to conversation

fix leak in btaudio

PATCH In review [email protected] 2 participants 3 messages Sep 29, 2003 – Oct 1, 2003 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix leak in btaudio

sound/oss/btaudio.c +4 -1
diff -urpN --exclude-from=/home/davej/.exclude bk-linus/sound/oss/btaudio.c linux-2.5/sound/oss/btaudio.c
@@ -177,8 +177,11 @@ static int alloc_buffer(struct btaudio *
 		bta->risc_size = PAGE_SIZE;
 		bta->risc_cpu = pci_alloc_consistent
 			(bta->pci, bta->risc_size, &bta->risc_dma);
-		if (NULL == bta->risc_cpu)
+		if (NULL == bta->risc_cpu) {
+			pci_free_consistent(bta->pci, bta->buf_size, bta->buf_cpu, bta->dma);
+			bta->buf_cpu = NULL;
 			return -ENOMEM;
+		}
 	}
 	return 0;
 }
#1 lore raw

Review

Quoted 1 line · On Monday, 29 September 2003 at 18:04:34 +0100, [email protected] wrote:
(quoted diff) +1 -0
+			pci_free_consistent(bta->pci, bta->buf_size, bta->buf_cpu, bta->dma);

Surely bta->dma must be bta->buf_dma, like so:

sound/oss/btaudio.c renamed from sound/oss/btaudio.c.~1~ +1 -1
@@ -178,7 +178,7 @@
 		bta->risc_cpu = pci_alloc_consistent
 			(bta->pci, bta->risc_size, &bta->risc_dma);
 		if (NULL == bta->risc_cpu) {
-			pci_free_consistent(bta->pci, bta->buf_size, bta->buf_cpu, bta->dma);
+			pci_free_consistent(bta->pci, bta->buf_size, bta->buf_cpu, bta->buf_dma);
 			bta->buf_cpu = NULL;
 			return -ENOMEM;
 		}

Cheers,
Sander

Signature · 2 lines
     Sander van Malssen -- [email protected] -- http://www.kozmix.org/
      http://www.peteandtommysdayout.com/ -- http://www.1-2-5.net/
author
#2 lore raw
Quoted 11 lines · Sander van Malssen

Review

Quoted 1 line · On Monday, 29 September 2003 at 18:04:34 +0100, [email protected] wrote:
(quoted diff) +1 -0
+			pci_free_consistent(bta->pci, bta->buf_size, bta->buf_cpu, bta->dma);

Surely bta->dma must be bta->buf_dma, like so:

sound/oss/btaudio.c line 184

Quoted 8 lines
sound/oss/btaudio.c renamed from sound/oss/btaudio.c.~1~ +1 -1
@@ -178,7 +178,7 @@
 		bta->risc_cpu = pci_alloc_consistent
 			(bta->pci, bta->risc_size, &bta->risc_dma);
 		if (NULL == bta->risc_cpu) {
-			pci_free_consistent(bta->pci, bta->buf_size, bta->buf_cpu, bta->dma);
+			pci_free_consistent(bta->pci, bta->buf_size, bta->buf_cpu, bta->buf_dma);
 			bta->buf_cpu = NULL;
 			return -ENOMEM;
 		}

Good eyes. Yes, looks correct to me.

Dave

Signature · 1 line
 Dave Jones     http://www.codemonkey.org.uk