diag: Protect the decrement of number of diag clients

In diagchar_open() protect the decrement of number of diag clients
so that there will be no race conditions while reading the value
from other functions.

Change-Id: I0e2fb5331eec9c7bba39e7d881b69559256833a3
Signed-off-by: Sreelakshmi Gownipalli <sgownipa@codeaurora.org>
This commit is contained in:
Sreelakshmi Gownipalli 2018-01-23 13:11:41 -08:00 committed by Gerrit - the friendly Code Review server
parent d99718532d
commit 6eb2f4f6fd

View file

@ -389,8 +389,8 @@ static int diagchar_open(struct inode *inode, struct file *file)
return -ENOMEM;
fail:
mutex_unlock(&driver->diagchar_mutex);
driver->num_clients--;
mutex_unlock(&driver->diagchar_mutex);
pr_err_ratelimited("diag: Insufficient memory for new client");
return -ENOMEM;
}