[EXT_EP-9988] NIMU Device object contains memory leak if NIMURegister() fails Created: 21/Aug/20 Updated: 21/Aug/20 Resolved: 21/Aug/20 |
|
| Status: | Fixed |
| Project: | Embedded Software & Tools |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Medium |
| Reporter: | TI User | Assignee: | TI User |
| Resolution: | Fixed | Votes: | 0 |
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Product: | TI Device Drivers |
| Internal ID: | TIDRIVERS-3834 |
| Found In Release: | 3.01.00 |
| Fix In Release: | TIDRIVERS_5_30_00 |
| Affected Platform/Device: | MSP432E4 |
| Release Notes: | Potential memory leak in NIMU Device object if NIMURegister() failed has been fixed. |
| Description |
|
Need to free the NIMU device object if NIMURegister() fails. In the NIMUInit() fxn, the NIMU device object is allocated using mmAlloc():
/* Allocate memory for the EMAC. Memory freed in the NDK stack shutdown */
device = mmAlloc(sizeof(NETIF_DEVICE));
if (device == NULL) {
return (-1);
}
Note first that if all goes well and NIMUInit() successfully returns, the allocated object will be freed later within the stack code in NIMU_UnRegister(). Otherwise, this object should be freed within the NIMUInit() function at various points of failure, and is, but there's one place that was overlooked before. In the below code, there should be a call to mmFree() prior to returning:
/* Register the device with NIMU */
if (NIMURegister(device) < 0) {
return (-1);
}
If NIMURegister() fails, then NIMU_UnRegister() is never called, and so no one will ever free the device. |