Re: [PATCH] DRM: Replace kmalloc/memset combos with kzalloc

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

 



On Wed, Aug 11, 2010 at 3:58 PM, Davidlohr Bueso <dave@xxxxxxx> wrote:
> On Wed, 2010-08-11 at 07:35 -0700, Joe Perches wrote:
>> On Wed, 2010-08-11 at 09:18 -0400, Davidlohr Bueso wrote:
>> > memory allocation in drm_bufs.c is followed by initializing the memory with 0.
>> >
>> > Replace the use of kmalloc+memset with kzalloc.
>>
>> Perhaps kzalloc's with a multiply could/should also be converted
>> to kcalloc.
>>
>> > +   entry->buflist = kzalloc(count * sizeof(*entry->buflist), GFP_KERNEL);
>>
>>       entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
>>
>> etc.
>>
>> > +   entry->buflist = kzalloc(count * sizeof(*entry->buflist), GFP_KERNEL);
>> > +   entry->seglist = kzalloc(count * sizeof(*entry->seglist), GFP_KERNEL);
>> > +   entry->buflist = kzalloc(count * sizeof(*entry->buflist),
>> > +   entry->buflist = kzalloc(count * sizeof(*entry->buflist),
>>
>
> Doable, but don't see much difference. David, what do you think?

kcalloc does an integer overflow check, plus it's nice to be explicit
about allocating a number of elements of a certain size in the API.

Kristian
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux