Skip to content

Commit

Permalink
soc/intel_adsp: ipc: initialize semaphore in driver init
Browse files Browse the repository at this point in the history
The ipc driver device data (struct intel_adsp_ipc_data) contains a
semaphore. Upon device init, the device data is zeroed out. This is safe
for other fields, but the semaphore should be properly initialized
before use.

This lack of initialization leads to a system crash when CONFIG_POLL is
enabled (e.g. to enable CONFIG_SHELL), IPC driver handles an interrupt
and executes k_sem_give() on a uninitialized semaphore object. This will
eventually lead to null dereference in z_handle_obj_poll_events().

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
  • Loading branch information
kv2019i committed Apr 30, 2024
1 parent 660149d commit f8b1cdd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions soc/intel/intel_adsp/common/ipc.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ int intel_adsp_ipc_init(const struct device *dev)

memset(devdata, 0, sizeof(*devdata));

k_sem_init(&devdata->sem, 0, 1);

/* ACK any latched interrupts (including TDA to clear IDA on
* the other side!), then enable.
*/
Expand Down

0 comments on commit f8b1cdd

Please sign in to comment.