If preemted during ion_free after the refcount is updated but before the handle can be removed from the rb_tree, import might find that handle in the tree and try to reuse it when execution returns to free, the handle will be cleaned up leaving the caller of import with a corrupt handle. This patch modifies the locking to protect agains this race. Change-Id: I31d18cc6398f0ca18e05cd919e2bcf86fa18d568 CRs-Fixed: 385283 Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com> [lauraa@codeaurora.org: Whitespace change and move unlock] Signed-off-by: Laura Abbott <lauraa@codeaurora.org> Signed-off-by: Ajay Dudani <adudani@codeaurora.org>