[alsa-devel] [PATCH] ALSA: hda: fix a locking bug in dead code

Dan Carpenter dan.carpenter at oracle.com
Fri Apr 21 22:55:56 CEST 2017


We added an impossible return to silence a static checker warning but it
introduced another warning because we need to drop the lock before
returning.

Fixes: 960a581e22d9 ("ALSA: hda: fix some klockwork scan warnings")
Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>

diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 90e4ff87445e..0dc18c4a3b1b 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1808,9 +1808,12 @@ static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid)
 	/* Add sanity check to pass klockwork check.
 	 * This should never happen.
 	 */
-	if (WARN_ON(spdif == NULL))
-		return true;
+	if (WARN_ON(spdif == NULL)) {
+		non_pcm = true;
+		goto unlock;
+	}
 	non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO);
+unlock:
 	mutex_unlock(&codec->spdif_mutex);
 	return non_pcm;
 }


More information about the Alsa-devel mailing list