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

From: Alessandro Rubini
Date: Wed Jun 19 2013 - 13:58:18 EST

>> + 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.
Even Kernighan said it was a design error (in "the practice of
programming"). That said, I'm not the leader here.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at