mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Fix potential leaks in pc300_tty driver
@ 2004-09-01 15:51 Dave Jones
  0 siblings, 0 replies; only message in thread
From: Dave Jones @ 2004-09-01 15:51 UTC (permalink / raw)
  To: linux-kernel

It appears that 'new' can be allocated, and next time around
the loop, if something goes wrong, we lose the reference..

Spotted with the source checker from Coverity.com.

Signed-off-by: Dave Jones <davej@redhat.com>


diff -urpN --exclude-from=/home/davej/.exclude bk-linus/drivers/net/wan/pc300_tty.c linux-2.6/drivers/net/wan/pc300_tty.c
--- bk-linus/drivers/net/wan/pc300_tty.c	2004-07-14 00:00:48.000000000 +0100
+++ linux-2.6/drivers/net/wan/pc300_tty.c	2004-08-23 14:08:15.000000000 +0100
@@ -789,6 +789,10 @@ void cpc_tty_receive(pc300dev_t *pc300de
 				cpc_writel(card->hw.scabase + DRX_REG(EDAL, ch), 
 						RX_BD_ADDR(ch, pc300chan->rx_last_bd)); 
 			}
+			if (new) {
+				kfree(new);
+				new = NULL;
+			}
 			return; 
 		}
 		
@@ -834,7 +838,8 @@ void cpc_tty_receive(pc300dev_t *pc300de
 						cpc_tty->name);
 				cpc_tty_rx_disc_frame(pc300chan);
 				rx_len = 0;
-				kfree((unsigned char *)new);
+				kfree(new);
+				new = NULL;
 				break; /* read next frame - while(1) */
 			}
 
@@ -843,7 +848,8 @@ void cpc_tty_receive(pc300dev_t *pc300de
 				cpc_tty_rx_disc_frame(pc300chan);
 				stats->rx_dropped++; 
 				rx_len = 0; 
-				kfree((unsigned char *)new);
+				kfree(new);
+				new = NULL;
 				break; /* read next frame - while(1) */
 			}
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-09-01 15:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-01 15:51 [PATCH] Fix potential leaks in pc300_tty driver Dave Jones

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

all inboxes | Powered by JetHome®