In the Linux kernel, the following vulnerability has been resolved:
misc: fastrpc: Fix use-after-free and race in fastrpcmapfind
Currently, there is a race window between the point when the mutex is unlocked in fastrpcmaplookup and the reference count increasing (fastrpcmapget) in fastrpcmapfind, which can also lead to use-after-free.
So lets merge fastrpcmapfind into fastrpcmaplookup which allows us to both protect the maps list by also taking the &fl->lock spinlock and the reference count, since the spinlock will be released only after. Add take_ref argument to make this suitable for all callers.