Re: [PATCH rdma-rc 6/7] IB/core: Fix incorrect array allocation

Doug Ledford
2016-06-07T13:43:29Z

[-- Attachment #1.1: Type: text/plain, Size: 1349 bytes --]

On 6/7/2016 3:16 AM, Leon Romanovsky wrote:
> On Mon, Jun 06, 2016 at 07:53:43PM -0400, Doug Ledford wrote:
>> On 6/4/2016 8:15 AM, Leon Romanovsky wrote:
>>> From: Mark Bloch <markb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
>>>
>>> In a attribute group struct, attrs should point to a NULL
>>> terminated list. Which means we need to allocate one more
>>> slot in the array.
>>
>> This patch is both right and wrong. You're right with the intent (that
>> there should be a total of 2 extra entries in the array size, one for
>> the NULL termination and one for the lifespan entry), but wrong with the
>> mechanics (unless I've missed something). We already have two extra
>> entries because sizeof(*hsag) includes our first counter, so just
>> num_counters is actually enough to NULL terminate the list, and + 1
>> gives us lifespan plus a NULL terminate spot. The comment could be
>> cleaned up to make this more clear though, so I'll do that.
>
> Thanks Doug.
>

I was wrong with this BTW (I tested to make sure). Even though the
struct includes the name for the array, because it's 0 length, it
reserves 0 space. I thought it would reserve one u64. In any case, I
ended up writing a fix of my own since I had already marked your patch
as not needed in patchworks. I listed Mark as the reporter in that patch.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]