Re: [PATCH v2 02/13] PCI: prevent duplicate slot names

From: Matthew Wilcox
Date: Mon Sep 22 2008 - 18:42:58 EST


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."
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/