Maybe the commit message is not elaborate. Here I prevent+ /* check if the value is already stored */>
>>+ if (array->events[index])
>>+ return -EINVAL;
>>+
>>+ /* convert the fd to the pointer to struct perf_event */
>>+ event = convert_map_with_perf_event(value);
>imo helper name is misleading and it's too short to be separate
>function. Just inline it and you can reuse 'index' variable.
>
>>+ if (!event)>
>>+ return -EBADF;
>>+
>>+ xchg(array->events + index, event);
>refcnt leak of old event! Please think it through.
>This type of bugs I shouldn't be finding.
user space from updating the existed event, so the return
value of xchg() is NULL and no refcnt leak of old event.
I will do the same as prog_array in next version.