Skip to content

Commit fdce3c3

Browse files
committed
WIP: user-space: avoid use of k_object_free() in user code
Add a warning and a comment to all places where k_object_free() is called in code that may be run in user threads. This will result in resource leaks, but there is currently no immediate solution to how to free these objects from user threads. We may need to revisit the partition of functionality between system and user. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1 parent 6ba732e commit fdce3c3

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/audio/dai-zephyr.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,12 @@ __cold void dai_common_free(struct dai_data *dd)
670670
dai_release_llp_slot(dd);
671671

672672
#ifdef CONFIG_SOF_USERSPACE_LL
673-
k_object_free(dd->dai->lock);
673+
/*
674+
* k_object_free() is not available to user-space, resources
675+
* are freed when thread terminates
676+
*/
677+
LOG_WRN("leaking semaphore as k_object_free() not available..");
678+
/*k_object_free(dd->dai->lock);*/
674679
#endif
675680

676681
dai_put(dd->dai);

src/include/sof/audio/component_ext.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ static inline void comp_free(struct comp_dev *dev)
5555
drv->ops.free(dev);
5656

5757
#ifdef CONFIG_SOF_USERSPACE_LL
58-
k_object_free(dev->list_mutex);
58+
/*
59+
* k_object_free() is not available to user-space, resources
60+
* are freed when thread terminates
61+
*/
62+
k_object_release(dev->list_mutex);
5963
#endif
6064
}
6165

src/schedule/zephyr_ll.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,12 @@ static int zephyr_ll_task_sched_free(void *data, struct task *task)
452452
k_sem_take(pdata->sem, K_USEC(LL_TIMER_PERIOD_US * 100));
453453

454454
#ifdef CONFIG_SOF_USERSPACE_LL
455-
k_object_free(pdata->sem);
455+
/*
456+
* k_object_free() is not available to user-space, resources
457+
* are freed when thread terminates
458+
*/
459+
LOG_WRN("leaking semaphore as k_object_free() not available..");
460+
/*k_object_free(pdata->sem);*/
456461
#endif
457462

458463
/* Protect against racing with schedule_task() */

0 commit comments

Comments
 (0)