Re: [patch -next] FMC: NULL dereference on allocation failure

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

 



On Wed, 2013-06-19 at 19:57 +0200, Alessandro Rubini wrote:
> >> +	arr->record = kzalloc(sizeof(arr->record[0]) * n, GFP_KERNEL);
> >> +	arr->subtree = kzalloc(sizeof(arr->subtree[0]) * n, GFP_KERNEL);
> 
> > n comes from the hardware no?
> 
> Yes. Length of hardware description array.
> 
> > Maybe make these kcalloc too.
> 
> I'm not a fan of kcalloc. I think it removes readability. I remeber
> kernel patches to swap the arguments, because people get them wrong.

kcalloc's sole benefit is multiplication overflow protection.
If sizes are small and known, kcalloc isn't particularly useful.

Those kcalloc arg swap patches were just for style with no net effect.

> Even Kernighan said it was a design error (in "the practice of
> programming").  That said, I'm not the leader here.

I think the real design pattern error was realloc()

Anyway, no worries...

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux