@@ -1097,8 +1097,8 @@ int sst_block_alloc_scratch(struct sst_dsp *dsp)
if (dsp->scratch_size == 0) {
dev_info(dsp->dev, "no modules need scratch buffer\n");
- mutex_unlock(&dsp->mutex);
- return 0;
+ ret = 0;
+ goto unlock;
}
/* allocate blocks for module scratch buffers */
@@ -1127,21 +1127,21 @@ int sst_block_alloc_scratch(struct sst_dsp *dsp)
}
if (ret < 0) {
dev_err(dsp->dev, "error: can't alloc scratch blocks\n");
- mutex_unlock(&dsp->mutex);
- return ret;
+ goto unlock;
}
ret = block_list_prepare(dsp, &dsp->scratch_block_list);
if (ret < 0) {
dev_err(dsp->dev, "error: scratch block prepare failed\n");
- mutex_unlock(&dsp->mutex);
- return ret;
+ goto unlock;
}
/* assign the same offset of scratch to each module */
dsp->scratch_offset = ba.offset;
+ ret = dsp->scratch_size;
+unlock:
mutex_unlock(&dsp->mutex);
- return dsp->scratch_size;
+ return ret;
}
EXPORT_SYMBOL_GPL(sst_block_alloc_scratch);