* Re: [PATCH] sound:hdmi:fix without unlocked before return
@ 2020-04-26 17:00 Markus Elfring
0 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2020-04-26 17:00 UTC (permalink / raw)
To: Wu Bo, alsa-devel
Cc: linux-kernel, kernel-janitors, Aaron Plattner, Feilong Lin,
Jaroslav Kysela, Kai Vehmanen, Libin Yang, Nikhil Mahale,
Pierre-Louis Bossart, Takashi Iwai, Zhiqiang Liu
> After add sanity check to pass klockwork check,
> The spdif_mutex should be unlock before return true
> in check_non_pcm_per_cvt().
How do you think about a wording variant like the following?
Subject:
[PATCH v2] ALSA: hda/hdmi: Unlock a mutex always before returning from check_non_pcm_per_cvt()
Change description (according to a solution alternative):
The exception handling was incomplete in an if branch for
a null pointer check of the variable “spdif”.
Thus assign an appropriate value to the local variable “non_pcm”
by using a conditional operator instead.
A mutex is also appropriately unlocked then.
…
> +++ b/sound/pci/hda/patch_hdmi.c
> @@ -1848,8 +1848,10 @@ static bool check_non_pcm_per_cvt(struct hda_codec *codec, hda_nid_t cvt_nid)
…
> - if (WARN_ON(spdif == NULL))
> + if (WARN_ON(spdif == NULL)) {
> + mutex_unlock(&codec->spdif_mutex);
> return true;
> + }
> non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO);
- if (WARN_ON(spdif == NULL))
- return true;
- non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO);
+ non_pcm = WARN_ON(!spdif)
+ ? true
+ : !!(spdif->status & IEC958_AES0_NONAUDIO);
mutex_unlock(&codec->spdif_mutex);
return non_pcm;
}
Would you like to add the tag “Fixes” to the change description?
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sound:hdmi:fix without unlocked before return
2020-04-29 7:27 ` Takashi Iwai
@ 2020-04-30 4:37 ` Wu Bo
0 siblings, 0 replies; 4+ messages in thread
From: Wu Bo @ 2020-04-30 4:37 UTC (permalink / raw)
To: Takashi Iwai
Cc: perex, tiwai, libin.yang, kai.vehmanen, nmahale, aplattner,
pierre-louis.bossart, linux-kernel, alsa-devel, liuzhiqiang26,
linfeilong
On 2020/4/29 15:27, Takashi Iwai wrote:
> On Sun, 26 Apr 2020 15:17:22 +0200,
> Wu Bo wrote:
>>
>> Fix the following coccicheck warning:
>> sound/pci/hda/patch_hdmi.c:1852:2-8: preceding lock on line 1846
>>
>> After add sanity check to pass klockwork check,
>> The spdif_mutex should be unlock before return true
>> in check_non_pcm_per_cvt().
>>
>> Signed-off-by: Wu Bo <wubo40@huawei.com>
>
> Applied now with the correction of subject and Fixes tag as well as
> Cc-to-stable tag.
>
>
> thanks,
>
> Takashi
>
> .
>
Thank you, I am sorry to forget to modify the V2 Patch version in time.
thanks,
Wu Bo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sound:hdmi:fix without unlocked before return
2020-04-26 13:17 Wu Bo
@ 2020-04-29 7:27 ` Takashi Iwai
2020-04-30 4:37 ` Wu Bo
0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2020-04-29 7:27 UTC (permalink / raw)
To: Wu Bo
Cc: perex, tiwai, libin.yang, kai.vehmanen, nmahale, aplattner,
pierre-louis.bossart, linux-kernel, alsa-devel, liuzhiqiang26,
linfeilong
On Sun, 26 Apr 2020 15:17:22 +0200,
Wu Bo wrote:
>
> Fix the following coccicheck warning:
> sound/pci/hda/patch_hdmi.c:1852:2-8: preceding lock on line 1846
>
> After add sanity check to pass klockwork check,
> The spdif_mutex should be unlock before return true
> in check_non_pcm_per_cvt().
>
> Signed-off-by: Wu Bo <wubo40@huawei.com>
Applied now with the correction of subject and Fixes tag as well as
Cc-to-stable tag.
thanks,
Takashi
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] sound:hdmi:fix without unlocked before return
@ 2020-04-26 13:17 Wu Bo
2020-04-29 7:27 ` Takashi Iwai
0 siblings, 1 reply; 4+ messages in thread
From: Wu Bo @ 2020-04-26 13:17 UTC (permalink / raw)
To: perex, tiwai, libin.yang, kai.vehmanen, nmahale, aplattner,
pierre-louis.bossart
Cc: linux-kernel, alsa-devel, liuzhiqiang26, linfeilong, wubo40
Fix the following coccicheck warning:
sound/pci/hda/patch_hdmi.c:1852:2-8: preceding lock on line 1846
After add sanity check to pass klockwork check,
The spdif_mutex should be unlock before return true
in check_non_pcm_per_cvt().
Signed-off-by: Wu Bo <wubo40@huawei.com>
---
sound/pci/hda/patch_hdmi.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
index 4eff1605..c24832b 100644
--- a/sound/pci/hda/patch_hdmi.c
+++ b/sound/pci/hda/patch_hdmi.c
@@ -1848,8 +1848,10 @@ 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))
+ if (WARN_ON(spdif == NULL)) {
+ mutex_unlock(&codec->spdif_mutex);
return true;
+ }
non_pcm = !!(spdif->status & IEC958_AES0_NONAUDIO);
mutex_unlock(&codec->spdif_mutex);
return non_pcm;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-30 4:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-26 17:00 [PATCH] sound:hdmi:fix without unlocked before return Markus Elfring
-- strict thread matches above, loose matches on Subject: below --
2020-04-26 13:17 Wu Bo
2020-04-29 7:27 ` Takashi Iwai
2020-04-30 4:37 ` Wu Bo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).