[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <84144f020801191623i2ad344a8t1c40969578793d13@mail.gmail.com>
Date: Sun, 20 Jan 2008 02:23:13 +0200
From: "Pekka Enberg" <penberg@...helsinki.fi>
To: trenn@...e.de
Cc: linux-acpi@...r.kernel.org, "Len Brown" <lenb@...nel.org>,
"Bjorn Helgaas" <bjorn.helgaas@...com>,
"Rene Herman" <rene.herman@...access.nl>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] Allocate pnp resources dynamically via krealloc
Hi Thomas,
On Jan 19, 2008 10:00 PM, Thomas Renninger <trenn@...e.de> wrote:
> +static int pnp_alloc_port(struct pnp_resource_table *res)
> +{
[snip]
> + res->port_resource = krealloc(res->port_resource,
> + (sizeof(struct resource) * res->allocated_ports)
> + + (sizeof(struct resource) * PNP_ALLOC_PORT), GFP_KERNEL);
> +
> + if (!res->port_resource)
> + return -ENOMEM;
When krealloc() returns NULL, there wasn't enough memory to fit the
new size but the original memory region remains unchanged. Therefore
you must not unconditionally overwrite the res->port_resource with the
return value of krealloc(); otherwise you might leak memory.
Pekka
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists