From: Julia Lawall <julia@diku.dk>
To: Patrick Gefre <pfg@sgi.com>
Cc: linux-ia64@vger.kernel.org, linux-mips@linux-mips.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 5/5] drivers/serial: Return -ENOMEM on memory allocation
Date: Wed, 11 Aug 2010 16:23:28 +0000 [thread overview]
Message-ID: <Pine.LNX.4.64.1008111818380.8669@ask.diku.dk> (raw)
In-Reply-To: <4C62C8F3.3090405@sgi.com>
> > I believe this code also leaks earlier instances of port, which are only
> > referenced by card_ptr, which is freed in the error handling code at the
> > end of the function. A lot of operations are done on port on each
> > iteration, however, so I'm not sure whether it is good enough to just free
> > them. Perhaps there is some way to call ioc3uart_remove?
> >
>
> Yes you are right, there should be something like this for out4:
>
> out4:
> for (phys_port = 0; phys_port < PORTS_PER_CARD; phys_port++) {
> port = card_ptr->ic_port[phys_port].icp_port;
> if (port) {
> pci_free_consistent(port->ip_idd->pdev,
> TOTAL_RING_BUF_SIZE,
> (void *)port->ip_cpu_ringbuf,
> port->ip_dma_ringbuf);
> kfree(port);
> }
> }
> kfree(card_ptr);
> return ret;
Actually, pci_alloc_consistent is only called when phys_port is 0. In the
subsequent cases, the ip_dma_ringbuf field is just initialized to the
previous value. So it could be:
out4:
for (phys_port = 0; phys_port < PORTS_PER_CARD; phys_port++) {
port = card_ptr->ic_port[phys_port].icp_port;
if (port) {
if (phys_port = 0)
pci_free_consistent(port->ip_idd->pdev,
TOTAL_RING_BUF_SIZE,
(void *)port->ip_cpu_ringbuf,
port->ip_dma_ringbuf);
kfree(port);
}
}
kfree(card_ptr);
return ret;
julia
prev parent reply other threads:[~2010-08-11 16:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-11 10:11 [PATCH 5/5] drivers/serial: Return -ENOMEM on memory allocation Julia Lawall
2010-08-11 15:59 ` Patrick Gefre
2010-08-11 16:23 ` Julia Lawall [this message]
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=Pine.LNX.4.64.1008111818380.8669@ask.diku.dk \
--to=julia@diku.dk \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-ia64@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=pfg@sgi.com \
/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