Loading
mhi: uci: Add channel mutex lock for read and write file ops
In case of two readers trying to read buffer one acquires spin
lock and populates uci_chan cur_buf and rx_size and local uci_buf.
After first one releases the spin lock other reader populates local
uci_buf with same cur_buf used by first reader. Second reader queues
the buffer to a TRE and releases the spinlock. Now first reader get
the spin lock and ends up copying 0 byte to user space buffer as the
rx_size becomes zero when second reader queues the buffer to transfer
ring. Now first reader queues the same buffer to a different TRE.
When dl xfer completion comes for both TREs, same buffer gets freed up
twice causes the double free. In case of a write it is possible that
two writers can race in case only one TRE is available to transfer the
request, although it does not result into any invalid access issue as in
case of read. Hence acquire channel mutex lock for both read and write
file operations to make sure read and write are done atomically.
Change-Id: I63bccedb28e1bfd59801ccdf642e4f70eb81021d
Signed-off-by:
Hemant Kumar <hemantk@codeaurora.org>