From: Alex Elder Date: Tue, 24 May 2016 18:34:48 +0000 (-0500) Subject: greybus: fix unbalanced mutex X-Git-Tag: v4.9-rc1~119^2~378^2~21^2~334 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=ebc9e3750d3112e3a84fe65386cb0e5deb994e18;p=karo-tx-linux.git greybus: fix unbalanced mutex Running "make coccicheck" on the Greybus code reports that gb_mmc_get_ro() and gb_mmc_get_cd() can return without releasing the mutex it acquired if there's an error. Fix this. Signed-off-by: Alex Elder Reviewed-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/sdio.c b/drivers/staging/greybus/sdio.c index 4d4cfdf8edb6..bdcc86923c54 100644 --- a/drivers/staging/greybus/sdio.c +++ b/drivers/staging/greybus/sdio.c @@ -684,9 +684,12 @@ static int gb_mmc_get_ro(struct mmc_host *mmc) struct gb_sdio_host *host = mmc_priv(mmc); mutex_lock(&host->lock); - if (host->removed) + if (host->removed) { + mutex_unlock(&host->lock); return -ESHUTDOWN; + } mutex_unlock(&host->lock); + return host->read_only; } @@ -695,9 +698,12 @@ static int gb_mmc_get_cd(struct mmc_host *mmc) struct gb_sdio_host *host = mmc_priv(mmc); mutex_lock(&host->lock); - if (host->removed) + if (host->removed) { + mutex_unlock(&host->lock); return -ESHUTDOWN; + } mutex_unlock(&host->lock); + return host->card_present; }