All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] sound/pci/hda/patch_realtek: don't call alc_shutup_pins without a spec
@ 2022-11-14  8:20 Daniil Tatianin
  2022-11-14  8:26   ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: Daniil Tatianin @ 2022-11-14  8:20 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Stefan Binding, lvc-project, Lucas Tanure, Meng Tang,
	Philipp Jungkamp, Tim Crawford, Takashi Iwai, Werner Sembach,
	linux-kernel, Kai-Heng Feng, yc-core, Daniil Tatianin, alsa-devel

alc_shutup_pins always expects the spec to be present, so make sure
it is before we call it.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
---
 sound/pci/hda/patch_realtek.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 60e3bc124836..2cf4b64971d7 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -939,10 +939,12 @@ static inline void alc_shutup(struct hda_codec *codec)
 {
 	struct alc_spec *spec = codec->spec;
 
+	if (!spec)
+		return;
 	if (!snd_hda_get_bool_hint(codec, "shutup"))
 		return; /* disabled explicitly by hints */
 
-	if (spec && spec->shutup)
+	if (spec->shutup)
 		spec->shutup(codec);
 	else
 		alc_shutup_pins(codec);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] sound/pci/hda/patch_realtek: don't call alc_shutup_pins without a spec
  2022-11-14  8:20 [PATCH v1] sound/pci/hda/patch_realtek: don't call alc_shutup_pins without a spec Daniil Tatianin
@ 2022-11-14  8:26   ` Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2022-11-14  8:26 UTC (permalink / raw)
  To: Daniil Tatianin
  Cc: Stefan Binding, lvc-project, Lucas Tanure, Meng Tang,
	Philipp Jungkamp, Tim Crawford, Takashi Iwai, Werner Sembach,
	Kai-Heng Feng, yc-core, alsa-devel, linux-kernel

On Mon, 14 Nov 2022 09:20:48 +0100,
Daniil Tatianin wrote:
> 
> alc_shutup_pins always expects the spec to be present, so make sure
> it is before we call it.
> 
> Found by Linux Verification Center (linuxtesting.org) with the SVACE
> static analysis tool.
> 
> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>

In which path can it be without spec assigned?
That's the internal callback that is set only by the codec driver
where the allocation of codec->spec is mandatory.


thanks,

Takashi


> ---
>  sound/pci/hda/patch_realtek.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
> index 60e3bc124836..2cf4b64971d7 100644
> --- a/sound/pci/hda/patch_realtek.c
> +++ b/sound/pci/hda/patch_realtek.c
> @@ -939,10 +939,12 @@ static inline void alc_shutup(struct hda_codec *codec)
>  {
>  	struct alc_spec *spec = codec->spec;
>  
> +	if (!spec)
> +		return;
>  	if (!snd_hda_get_bool_hint(codec, "shutup"))
>  		return; /* disabled explicitly by hints */
>  
> -	if (spec && spec->shutup)
> +	if (spec->shutup)
>  		spec->shutup(codec);
>  	else
>  		alc_shutup_pins(codec);
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] sound/pci/hda/patch_realtek: don't call alc_shutup_pins without a spec
@ 2022-11-14  8:26   ` Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2022-11-14  8:26 UTC (permalink / raw)
  To: Daniil Tatianin
  Cc: Jaroslav Kysela, Takashi Iwai, Tim Crawford, Stefan Binding,
	Kai-Heng Feng, Meng Tang, Lucas Tanure, Philipp Jungkamp,
	Werner Sembach, alsa-devel, linux-kernel, lvc-project, yc-core

On Mon, 14 Nov 2022 09:20:48 +0100,
Daniil Tatianin wrote:
> 
> alc_shutup_pins always expects the spec to be present, so make sure
> it is before we call it.
> 
> Found by Linux Verification Center (linuxtesting.org) with the SVACE
> static analysis tool.
> 
> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>

In which path can it be without spec assigned?
That's the internal callback that is set only by the codec driver
where the allocation of codec->spec is mandatory.


thanks,

Takashi


> ---
>  sound/pci/hda/patch_realtek.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
> index 60e3bc124836..2cf4b64971d7 100644
> --- a/sound/pci/hda/patch_realtek.c
> +++ b/sound/pci/hda/patch_realtek.c
> @@ -939,10 +939,12 @@ static inline void alc_shutup(struct hda_codec *codec)
>  {
>  	struct alc_spec *spec = codec->spec;
>  
> +	if (!spec)
> +		return;
>  	if (!snd_hda_get_bool_hint(codec, "shutup"))
>  		return; /* disabled explicitly by hints */
>  
> -	if (spec && spec->shutup)
> +	if (spec->shutup)
>  		spec->shutup(codec);
>  	else
>  		alc_shutup_pins(codec);
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] sound/pci/hda/patch_realtek: don't call alc_shutup_pins without a spec
  2022-11-14  8:26   ` Takashi Iwai
  (?)
@ 2022-11-14  8:35   ` Daniil Tatianin
  2022-11-14  8:54       ` Takashi Iwai
  -1 siblings, 1 reply; 6+ messages in thread
From: Daniil Tatianin @ 2022-11-14  8:35 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Stefan Binding, lvc-project, Lucas Tanure, Meng Tang,
	Philipp Jungkamp, Tim Crawford, Takashi Iwai, Werner Sembach,
	Kai-Heng Feng, yc-core, alsa-devel, linux-kernel



On 11/14/22 11:26 AM, Takashi Iwai wrote:
> On Mon, 14 Nov 2022 09:20:48 +0100,
> Daniil Tatianin wrote:
>>
>> alc_shutup_pins always expects the spec to be present, so make sure
>> it is before we call it.
>>
>> Found by Linux Verification Center (linuxtesting.org) with the SVACE
>> static analysis tool.
>>
>> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
> 
> In which path can it be without spec assigned?
> That's the internal callback that is set only by the codec driver
> where the allocation of codec->spec is mandatory.

Would you then say that the "if (spec && ...)" that was there before was 
redundant? Should we remove it perhaps to avoid further confusion about 
it being optional? The else branch with alc_shutup_pins would crash if 
it was null anyway.

Thanks

> 
> thanks,
> 
> Takashi
> 
> 
>> ---
>>   sound/pci/hda/patch_realtek.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
>> index 60e3bc124836..2cf4b64971d7 100644
>> --- a/sound/pci/hda/patch_realtek.c
>> +++ b/sound/pci/hda/patch_realtek.c
>> @@ -939,10 +939,12 @@ static inline void alc_shutup(struct hda_codec *codec)
>>   {
>>   	struct alc_spec *spec = codec->spec;
>>   
>> +	if (!spec)
>> +		return;
>>   	if (!snd_hda_get_bool_hint(codec, "shutup"))
>>   		return; /* disabled explicitly by hints */
>>   
>> -	if (spec && spec->shutup)
>> +	if (spec->shutup)
>>   		spec->shutup(codec);
>>   	else
>>   		alc_shutup_pins(codec);
>> -- 
>> 2.25.1
>>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] sound/pci/hda/patch_realtek: don't call alc_shutup_pins without a spec
  2022-11-14  8:35   ` Daniil Tatianin
@ 2022-11-14  8:54       ` Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2022-11-14  8:54 UTC (permalink / raw)
  To: Daniil Tatianin
  Cc: Stefan Binding, lvc-project, Lucas Tanure, Meng Tang,
	Philipp Jungkamp, Tim Crawford, Takashi Iwai, Werner Sembach,
	Kai-Heng Feng, yc-core, alsa-devel, linux-kernel

On Mon, 14 Nov 2022 09:35:10 +0100,
Daniil Tatianin wrote:
> 
> 
> 
> On 11/14/22 11:26 AM, Takashi Iwai wrote:
> > On Mon, 14 Nov 2022 09:20:48 +0100,
> > Daniil Tatianin wrote:
> >> 
> >> alc_shutup_pins always expects the spec to be present, so make sure
> >> it is before we call it.
> >> 
> >> Found by Linux Verification Center (linuxtesting.org) with the SVACE
> >> static analysis tool.
> >> 
> >> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
> > 
> > In which path can it be without spec assigned?
> > That's the internal callback that is set only by the codec driver
> > where the allocation of codec->spec is mandatory.
> 
> Would you then say that the "if (spec && ...)" that was there before
> was redundant?

Yes.


Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1] sound/pci/hda/patch_realtek: don't call alc_shutup_pins without a spec
@ 2022-11-14  8:54       ` Takashi Iwai
  0 siblings, 0 replies; 6+ messages in thread
From: Takashi Iwai @ 2022-11-14  8:54 UTC (permalink / raw)
  To: Daniil Tatianin
  Cc: Jaroslav Kysela, Takashi Iwai, Tim Crawford, Stefan Binding,
	Kai-Heng Feng, Meng Tang, Lucas Tanure, Philipp Jungkamp,
	Werner Sembach, alsa-devel, linux-kernel, lvc-project, yc-core

On Mon, 14 Nov 2022 09:35:10 +0100,
Daniil Tatianin wrote:
> 
> 
> 
> On 11/14/22 11:26 AM, Takashi Iwai wrote:
> > On Mon, 14 Nov 2022 09:20:48 +0100,
> > Daniil Tatianin wrote:
> >> 
> >> alc_shutup_pins always expects the spec to be present, so make sure
> >> it is before we call it.
> >> 
> >> Found by Linux Verification Center (linuxtesting.org) with the SVACE
> >> static analysis tool.
> >> 
> >> Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
> > 
> > In which path can it be without spec assigned?
> > That's the internal callback that is set only by the codec driver
> > where the allocation of codec->spec is mandatory.
> 
> Would you then say that the "if (spec && ...)" that was there before
> was redundant?

Yes.


Takashi

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-14  8:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-14  8:20 [PATCH v1] sound/pci/hda/patch_realtek: don't call alc_shutup_pins without a spec Daniil Tatianin
2022-11-14  8:26 ` Takashi Iwai
2022-11-14  8:26   ` Takashi Iwai
2022-11-14  8:35   ` Daniil Tatianin
2022-11-14  8:54     ` Takashi Iwai
2022-11-14  8:54       ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.