Commit 94ca99b
committed
ipc: fix component teardown crashes and memory leaks
Fuzzing identified several segmentation faults and memory corruptions
in ipc_comp_free() when processing malformed IPC messages or handling
uninitialized component lists.
This patch implements three defensive structural fixes to harden teardown logic:
1. Validates that `icd->cd` is not NULL before checking component state
to avoid early NULL pointer dereferences on broken components.
2. Resolves a deliberate memory leak ("eat the resulting memory leak
on error") when encountering uninitialized buffer lists. Instead of
leaking the structure and leaving it hanging in `ipc->comp_list`
(which triggers secondary use-after-free assertions and segfaults
in subsequent IPC calls), the component is now properly removed
and freed.
3. Moves `list_item_del(&icd->list)` to occur immediately before
`comp_free(icd->cd)`. This guarantees that other tasks or scheduling
interrupts cannot discover and access a partially destructed component
via the global IPC list.
Signed-off-by: Liam Girdwood <[email protected]>1 parent 9c5a577 commit 94ca99b
1 file changed
Lines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
306 | 313 | | |
307 | 314 | | |
308 | 315 | | |
| |||
324 | 331 | | |
325 | 332 | | |
326 | 333 | | |
327 | | - | |
328 | | - | |
329 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
330 | 337 | | |
331 | 338 | | |
332 | 339 | | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
333 | 344 | | |
334 | 345 | | |
335 | 346 | | |
| |||
348 | 359 | | |
349 | 360 | | |
350 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
351 | 365 | | |
352 | 366 | | |
353 | 367 | | |
354 | 368 | | |
355 | 369 | | |
356 | | - | |
357 | 370 | | |
358 | 371 | | |
359 | 372 | | |
| |||
0 commit comments