public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [CHECKER] 6 memory leaks
@ 2003-04-21 20:27 Jean Tourrilhes
  2003-04-21 20:53 ` William Lee Irwin III
  0 siblings, 1 reply; 9+ messages in thread
From: Jean Tourrilhes @ 2003-04-21 20:27 UTC (permalink / raw)
  To: irda-users, Muli Ben-Yehuda, William Lee Irwin III
  Cc: Linux kernel mailing list

William Lee Irwin III wrote :
>
> On Sat, Apr 19, 2003 at 12:44:45PM +0300, Muli Ben-Yehuda wrote:
> > Index: net/irda/irttp.c
> > ===================================================================
> > RCS file: /home/cvs/linux-2.5/net/irda/irttp.c,v
> > retrieving revision 1.12
> > diff -u -r1.12 irttp.c
> > --- net/irda/irttp.c	25 Feb 2003 05:02:46 -0000	1.12
> > +++ net/irda/irttp.c	19 Apr 2003 08:50:00 -0000
> > @@ -263,7 +263,7 @@
> >  
> >  	IRDA_DEBUG(2, "%s(), rx_sdu_size=%d\n",  __FUNCTION__,
> >  		   self->rx_sdu_size);
> > -	ASSERT(n <= self->rx_sdu_size, return NULL;);
> > +	ASSERT(n <= self->rx_sdu_size, {dev_kfree_skb(skb); return NULL;});
> >  
> >  	/* Set the new length */
> >  	skb_trim(skb, n);

	Thanks for the heads up. I'm preparing a massive skb leak
patch for 2.5.X, I'll slip that into it. I'll probably code that
differently so that it looks "cleaner".
	By the way, this is not terribly important, as if ASSERT do
trigger we usually have bigger problems than memory leaks (like you
may want to reboot rather sooner than later).

> I'm in terror. ASSERT()? return NULL in a macro argument?
> Any chance of cleaning that up a bit while you're at it?
> 
> -- wli

	Rather than fixing imaginary non-existing bugs, I prefer to
spend my time fixing real bugs that byte real users. This construct is
perfectly sound and valid, and it needs to be done in this way, the
only issue is that someone should rename "ASSERT" into "IRDA_ASSERT".

	Have fun...

	Jean

^ permalink raw reply	[flat|nested] 9+ messages in thread
* [CHECKER] 6 memory leaks
@ 2003-04-19  2:50 Andy Chou
  2003-04-19  9:44 ` Muli Ben-Yehuda
  0 siblings, 1 reply; 9+ messages in thread
From: Andy Chou @ 2003-04-19  2:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: mc, madan, wendy.cheng

[-- Attachment #1: Type: text/plain, Size: 344 bytes --]

The following memory leaks were found by static analysis using the MC
system (aka "Stanford Checker").  This is only an incremental list of new
bugs found by an updated version of the memory leak checker.  I checked
the ipv4 and ipv6 bugs and they are still in 2.5.67.

Confirmation/rejection would be appreciated for any of these bugs.

-Andy

[-- Attachment #2: err --]
[-- Type: text/plain, Size: 3792 bytes --]

---------------------------------------------------------
[BUG] 
/u1/acc/linux/2.5.48/net/ipv4/netfilter/ip_queue.c:321:ipq_enqueue_packet: ERROR:LEAK:296:321:Memory leak [Allocated from: /u1/acc/linux/2.5.48/net/ipv4/netfilter/ip_queue.c:296:ipq_build_packet_message]

		entry->rt_info.tos = iph->tos;
		entry->rt_info.daddr = iph->daddr;
		entry->rt_info.saddr = iph->saddr;
	}

Start --->
	nskb = ipq_build_packet_message(entry, &status);

	... DELETED 19 lines ...

err_out_unlock:
	write_unlock_bh(&queue_lock);

err_out_free:
	kfree(entry);
Error --->
	return status;
}

static int
---------------------------------------------------------
[BUG] 
/u1/acc/linux/2.5.48/net/ipv6/netfilter/ip6_queue.c:326:ipq_enqueue_packet: ERROR:LEAK:301:326:Memory leak [Allocated from: /u1/acc/linux/2.5.48/net/ipv6/netfilter/ip6_queue.c:301:ipq_build_packet_message]


		entry->rt_info.daddr = iph->daddr;
		entry->rt_info.saddr = iph->saddr;
	}

Start --->
	nskb = ipq_build_packet_message(entry, &status);

	... DELETED 19 lines ...

err_out_unlock:
	write_unlock_bh(&queue_lock);

err_out_free:
	kfree(entry);
Error --->
	return status;
}

/*
---------------------------------------------------------
[BUG] 
/u1/acc/linux/2.5.48/net/irda/irttp.c:266:irttp_reassemble_skb: ERROR:LEAK:242:266:Memory leak [Allocated from: /u1/acc/linux/2.5.48/net/irda/irttp.c:242:dev_alloc_skb]

	ASSERT(self->magic == TTP_TSAP_MAGIC, return NULL;);

	IRDA_DEBUG(2, "%s(), self->rx_sdu_size=%d\n", __FUNCTION__,
		   self->rx_sdu_size);

Start --->
	skb = dev_alloc_skb(TTP_HEADER + self->rx_sdu_size);

	... DELETED 18 lines ...

	}
	IRDA_DEBUG(2, "%s(), frame len=%d\n",  __FUNCTION__, n);

	IRDA_DEBUG(2, "%s(), rx_sdu_size=%d\n",  __FUNCTION__,
		   self->rx_sdu_size);
Error --->
	ASSERT(n <= self->rx_sdu_size, return NULL;);

	/* Set the new length */
	skb_trim(skb, n);
---------------------------------------------------------
[BUG]
/u1/acc/linux/2.5.48/drivers/isdn/tpam/tpam_queues.c:150:tpam_irq: ERROR:LEAK:112:150:Memory leak [Allocated from: /u1/acc/linux/2.5.48/drivers/isdn/tpam/tpam_queues.c:112:alloc_skb]

		
		/* get the beginning of the message (pci_mpb part) */
		copy_from_pam(card, &mpb, (void *)uploadptr, sizeof(pci_mpb));

		/* allocate the sk_buff */
Start --->
		if (!(skb = alloc_skb(sizeof(skb_header) + sizeof(pci_mpb) + 

	... DELETED 32 lines ...

			hpic = readl(card->bar0 + TPAM_HPIC_REGISTER);
			if (waiting_too_long++ > 0xfffffff) {
				spin_unlock(&card->lock);
				printk(KERN_ERR "TurboPAM(tpam_irq): "
						"waiting too long...\n");
Error --->
				return;
			}
		} while (hpic & 0x00000002);

---------------------------------------------------------
[BUG]
/u1/acc/linux/2.5.48/drivers/net/wan/sdla_ppp.c:1921:rx_intr: ERROR:LEAK:1830:1921:Memory leak [Allocated from: /u1/acc/linux/2.5.48/drivers/net/wan/sdla_ppp.c:1830:dev_alloc_skb]

	
		len  = rxbuf->length;
		ppp_priv_area = dev->priv;

		/* Allocate socket buffer */
Start --->
		skb = dev_alloc_skb(len);

	... DELETED 85 lines ...

	/* Release buffer element and calculate a pointer to the next one */
	rxbuf->flag = 0x00;
	card->rxmb = ++rxbuf;
	if ((void*)rxbuf > card->u.p.rxbuf_last)
		card->rxmb = card->u.p.rxbuf_base;
Error --->
}


void event_intr (sdla_t *card)
---------------------------------------------------------
[BUG]
/u1/acc/linux/2.5.48/net/ax25/af_ax25.c:1294:ax25_connect: ERROR:LEAK:1168:1294:Memory leak [Allocated from: /u1/acc/linux/2.5.48/net/ax25/af_ax25.c:1168:kmalloc]

		if (fsa->fsa_ax25.sax25_ndigis < 1 || fsa->fsa_ax25.sax25_ndigis > AX25_MAX_DIGIS) {
			err = -EINVAL;
			goto out;
		}

Start --->
		if ((digi = kmalloc(sizeof(ax25_digi), GFP_KERNEL)) == NULL) {

	... DELETED 120 lines ...

	sock->state = SS_CONNECTED;

out:
	release_sock(sk);

Error --->
	return 0;
}




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

end of thread, other threads:[~2003-04-21 20:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-21 20:27 [CHECKER] 6 memory leaks Jean Tourrilhes
2003-04-21 20:53 ` William Lee Irwin III
  -- strict thread matches above, loose matches on Subject: below --
2003-04-19  2:50 Andy Chou
2003-04-19  9:44 ` Muli Ben-Yehuda
2003-04-19  9:55   ` William Lee Irwin III
2003-04-19 10:02     ` Muli Ben-Yehuda
2003-04-19 10:13       ` William Lee Irwin III
2003-04-19 12:08   ` James Morris
2003-04-19 12:28     ` Muli Ben-Yehuda

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