Protect the move operation of buflib against IRQs.
This makes accessing the buffers with core_get_data() from interrupt context safe, other buflib functions aren't really safe (yet). git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30736 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
227c7af9b3
commit
aed39dbbaf
1 changed files with 10 additions and 0 deletions
|
@ -206,16 +206,26 @@ move_block(struct buflib_context* ctx, union buflib_data* block, int shift)
|
|||
handle, shift, shift*sizeof(union buflib_data));
|
||||
new_block = block + shift;
|
||||
new_start = tmp->alloc + shift*sizeof(union buflib_data);
|
||||
|
||||
/* disable IRQs to make accessing the buffer from interrupt context safe. */
|
||||
/* protect the move callback, as a cached global pointer might be updated
|
||||
* in it. and protect "tmp->alloc = new_start" for buflib_get_data() */
|
||||
disable_irq();
|
||||
/* call the callback before moving */
|
||||
if (ops)
|
||||
{
|
||||
if (ops->move_callback(handle, tmp->alloc, new_start)
|
||||
== BUFLIB_CB_CANNOT_MOVE)
|
||||
{
|
||||
enable_irq();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
tmp->alloc = new_start; /* update handle table */
|
||||
memmove(new_block, block, block->val * sizeof(union buflib_data));
|
||||
|
||||
enable_irq();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue