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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux