Re: [PATCH v3 7/7] staging: dgnc: tty.c: replaces kzalloc with kcalloc for arrays

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

 



On Tue, Sep 10, 2013 at 6:05 PM, Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
> This one is not right.
>
> On Mon, Sep 09, 2013 at 03:01:28PM -0400, Lidza Louina wrote:
>> This patch replaces kzalloc with kcalloc when using
>> arrays. kcalloc is better suited for arrays because
>> it has overflow protection.
>>
>> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
>> Signed-off-by: Lidza Louina <lidza.louina@xxxxxxxxx>
>> ---
>>  drivers/staging/dgnc/dgnc_tty.c | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
>> index 07b79be..18705f9 100644
>> --- a/drivers/staging/dgnc/dgnc_tty.c
>> +++ b/drivers/staging/dgnc/dgnc_tty.c
>> @@ -222,12 +222,12 @@ int dgnc_tty_register(struct dgnc_board *brd)
>>        * The kernel wants space to store pointers to
>>        * tty_struct's and termios's.
>>        */
>> -     brd->SerialDriver.ttys = kzalloc(brd->maxports * sizeof(*brd->SerialDriver.ttys), GFP_KERNEL);
>> +     brd->SerialDriver.ttys = kcalloc(brd->SerialDriver.num, brd->maxports * sizeof(*brd->SerialDriver.ttys), GFP_KERNEL);
>
>
> This should be:
>
>         brd->SerialDriver.ttys = kcalloc(brd->maxports, sizeof(*brd->SerialDriver.ttys), GFP_KERNEL);
>
> Btw, are you using vim with cscope set up?
>
> make cscope
> vim -t kcalloc
> Move to the kmalloc_array() call and hit CTRL-]

I had never heard of cscope. I wish I would've known
about it before, it would've saved me a ton of grepping
thru source code... >_< Thanks for the tip.
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux