aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/staging/greybus/sdio.c
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2016-05-24 13:34:48 -0500
committerGreg Kroah-Hartman <gregkh@google.com>2016-05-27 11:28:16 -0700
commitebc9e3750d3112e3a84fe65386cb0e5deb994e18 (patch)
tree12c22d1a72de72537e32e8e8b6e4110402383a1a /drivers/staging/greybus/sdio.c
parentgreybus: report right error value (diff)
downloadwireguard-linux-ebc9e3750d3112e3a84fe65386cb0e5deb994e18.tar.xz
wireguard-linux-ebc9e3750d3112e3a84fe65386cb0e5deb994e18.zip
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 <elder@linaro.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/sdio.c')
-rw-r--r--drivers/staging/greybus/sdio.c10
1 files changed, 8 insertions, 2 deletions
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;
}