lkml.org 
[lkml]   [2008]   [Jan]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] Allocate pnp resources dynamically via krealloc
From
Date

On Sun, 2008-01-20 at 02:23 +0200, Pekka Enberg wrote:
> Hi Thomas,
>
> On Jan 19, 2008 10:00 PM, Thomas Renninger <trenn@suse.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.
>
Thanks.
While looking at this I found something else..., I think I sent an old
version.

Please hold off, I will double check and resend soon.

Thomas



\
 
 \ /
  Last update: 2008-01-20 12:07    [W:0.111 / U:2.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site