aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/firmware_class.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 06ed6b4e7df5..3719c94be19c 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -226,13 +226,13 @@ static ssize_t firmware_loading_store(struct device *dev,
226 int loading = simple_strtol(buf, NULL, 10); 226 int loading = simple_strtol(buf, NULL, 10);
227 int i; 227 int i;
228 228
229 mutex_lock(&fw_lock);
230
231 if (!fw_priv->fw)
232 goto out;
233
229 switch (loading) { 234 switch (loading) {
230 case 1: 235 case 1:
231 mutex_lock(&fw_lock);
232 if (!fw_priv->fw) {
233 mutex_unlock(&fw_lock);
234 break;
235 }
236 firmware_free_data(fw_priv->fw); 236 firmware_free_data(fw_priv->fw);
237 memset(fw_priv->fw, 0, sizeof(struct firmware)); 237 memset(fw_priv->fw, 0, sizeof(struct firmware));
238 /* If the pages are not owned by 'struct firmware' */ 238 /* If the pages are not owned by 'struct firmware' */
@@ -243,7 +243,6 @@ static ssize_t firmware_loading_store(struct device *dev,
243 fw_priv->page_array_size = 0; 243 fw_priv->page_array_size = 0;
244 fw_priv->nr_pages = 0; 244 fw_priv->nr_pages = 0;
245 set_bit(FW_STATUS_LOADING, &fw_priv->status); 245 set_bit(FW_STATUS_LOADING, &fw_priv->status);
246 mutex_unlock(&fw_lock);
247 break; 246 break;
248 case 0: 247 case 0:
249 if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) { 248 if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) {
@@ -274,7 +273,8 @@ static ssize_t firmware_loading_store(struct device *dev,
274 fw_load_abort(fw_priv); 273 fw_load_abort(fw_priv);
275 break; 274 break;
276 } 275 }
277 276out:
277 mutex_unlock(&fw_lock);
278 return count; 278 return count;
279} 279}
280 280