Fixed coverity reported concurrency issues

Signed-off-by: Santhosh Edukulla <santhosh.edukulla@gmail.com>