Re: [PATCHv3 1/9] extcon: Add extcon_dev_allocate/free() to control the memory of extcon device

From: Chanwoo Choi
Date: Thu Apr 24 2014 - 11:06:26 EST


On Fri, Apr 25, 2014 at 12:03 AM, Felipe Balbi <balbi@xxxxxx> wrote:
> Hi,
>
> On Thu, Apr 24, 2014 at 11:58:29PM +0900, Chanwoo Choi wrote:
>> >> +void extcon_dev_free(struct extcon_dev *edev)
>> >> +{
>> >> + if (edev)
>> >> + kfree(edev);
>> >
>> > kfree(NULL) is safe
>>
>> I don't understand about meaning 'kfree(NULL)'.
>> Why do I free 'NULL' pointer' instead of 'edev' pointer?
>
> you don't need to check if evdev is valid before calling kfree() on it
> because if it happens to be NULL, no cute bunnies will be sacrificed.
>

OK, I'll fix it as following code without checking whether 'edev' is
NULL or not.

void extcon_dev_free(struct extcon_dev *edev)
{
kfree(edev);
}

Thanks,
Chanwoo Choi
--
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/