diag: Add protection while de-initializing clients
Currently, while de-initializing clients, there is a possibility of using already freed memory. The patch adds proper protection to fix the issue. CRs-Fixed: 2068569 Change-Id: I4b397a82e03fa2f1c84cfa8ca912cdb6a51ba08b Signed-off-by: Mohit Aggarwal <maggarwa@codeaurora.org>
This commit is contained in:
parent
9fa4a186c0
commit
c032cdd08e
1 changed files with 5 additions and 1 deletions
|
@ -1836,14 +1836,18 @@ static int diag_ioctl_lsm_deinit(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
mutex_lock(&driver->diagchar_mutex);
|
||||||
for (i = 0; i < driver->num_clients; i++)
|
for (i = 0; i < driver->num_clients; i++)
|
||||||
if (driver->client_map[i].pid == current->tgid)
|
if (driver->client_map[i].pid == current->tgid)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (i == driver->num_clients)
|
if (i == driver->num_clients) {
|
||||||
|
mutex_unlock(&driver->diagchar_mutex);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
driver->data_ready[i] |= DEINIT_TYPE;
|
driver->data_ready[i] |= DEINIT_TYPE;
|
||||||
|
mutex_unlock(&driver->diagchar_mutex);
|
||||||
wake_up_interruptible(&driver->wait_q);
|
wake_up_interruptible(&driver->wait_q);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue