In the Linux kernel, the following vulnerability has been resolved:
powerpc/paprscm: Fix leaking nvdimmevents_map elements
Right now 'char *' elements allocated for individual 'statid' in 'paprscmpriv.nvdimmeventsmap[]' during paprscmpmucheckevents(), get leaked in paprscmremove() and paprscmpmuregister(), paprscmpmucheckevents() error paths.
Also individual 'statid' arent NULL terminated 'char *' instead they are fixed 8-byte sized identifiers. However paprscmpmuregister() assumes it to be a NULL terminated 'char *' and at other places it assumes it to be a 'paprscmperfstat.statid' sized string which is 8-byes in size.
Fix this by allocating the memory for paprscmpriv.nvdimmeventsmap to also include space for 'statid' entries. This is possible since number of available events/statids are known upfront. This saves some memory and one extra level of indirection from 'nvdimmeventsmap' to 'statid'. Also rest of the code can continue to call 'kfree(paprscmpriv.nvdimmevents_map)' without needing to iterate over the array and free up individual elements.