Fix a recently introduced deadlock in some class drivers

This commit is contained in:
Gregory Nutt 2015-04-25 15:57:57 -06:00
parent 4de9bc7b6c
commit 329ae78583
2 changed files with 15 additions and 5 deletions

View File

@ -2165,6 +2165,11 @@ static int usbhost_close(FAR struct file *filep)
*/
usbhost_destroy(priv);
/* Skip giving the semaphore... it is no longer valid */
irqrestore(flags);
return OK;
}
else /* if (priv->crefs == 1) */
{
@ -2173,12 +2178,12 @@ static int usbhost_close(FAR struct file *filep)
* signal that we use does not matter in this case.
*/
(void)kill(priv->pollpid, SIGUSR1);
usbhost_givesem(&priv->exclsem);
(void)kill(priv->pollpid, SIGALRM);
}
}
}
usbhost_givesem(&priv->exclsem);
irqrestore(flags);
return OK;
}

View File

@ -2254,6 +2254,11 @@ static int usbhost_close(FAR struct file *filep)
*/
usbhost_destroy(priv);
/* Skip giving the semaphore... it is no longer valid */
irqrestore(flags);
return OK;
}
else /* if (priv->crefs == 1) */
{
@ -2262,12 +2267,12 @@ static int usbhost_close(FAR struct file *filep)
* signal that we use does not matter in this case.
*/
(void)kill(priv->pollpid, SIGUSR1);
usbhost_givesem(&priv->exclsem);
(void)kill(priv->pollpid, SIGALRM);
}
}
}
usbhost_givesem(&priv->exclsem);
irqrestore(flags);
return OK;
}