lkml.org 
[lkml]   [2008]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 02/13] PCI: prevent duplicate slot names
On Mon, Sep 22, 2008 at 03:38:45PM -0600, Alex Chiang wrote:
> As Rolf Eike Beer pointed out, a failed krealloc() will leak the
> old version of new_name, so I did this instead:
>
> kfree(new_name);
> new_name = kmalloc(len, GFP_KERNEL);
>
> This is better than krealloc() in several ways:
>
> 1. we avoid the unneeded memcpy that krealloc() does for
> us. we don't need it because we're going to sprintf over
> it anyway.
>
> 2. the explicit kfree(new_name) means we won't leak
> anything.

Agreed.

--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."


\
 
 \ /
  Last update: 2008-09-23 00:45    [W:2.551 / U:0.604 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site