lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Sun, 19 Nov 2017 10:56:37 +0100
From:   SF Markus Elfring <elfring@...rs.sourceforge.net>
To:     alsa-devel@...a-project.org, Arnd Bergmann <arnd@...db.de>,
        Colin Ian King <colin.king@...onical.com>,
        Jaroslav Kysela <perex@...ex.cz>,
        Jie Yang <yang.jie@...ux.intel.com>,
        Liam Girdwood <lgirdwood@...il.com>,
        Mark Brown <broonie@...nel.org>, Takashi Iwai <tiwai@...e.com>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org
Subject: [PATCH] ASoC: sst-firmware: Improve unlocking of a mutex in
 sst_block_alloc_scratch()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Sun, 19 Nov 2017 10:45:36 +0100

* Add a jump target so that a call of the function "mutex_unlock" is stored
  only once in this function implementation.

* Replace three calls by goto statements.

* Increase the lock scope.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 sound/soc/intel/common/sst-firmware.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c
index 79a9fdf94d38..665e66670512 100644
--- a/sound/soc/intel/common/sst-firmware.c
+++ b/sound/soc/intel/common/sst-firmware.c
@@ -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);
 
-- 
2.15.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ