Minor fixes for CS35L41 HDA Property driver
cover Minor fixes for CS35L41 HDA Property driver
Minor issues were found in static analysis.
First fix ensures unitialised variables will never be freed. Second fix only compiles in the SPI workaround if SPI is enabled in the kernel.
Stefan Binding (2):
ALSA: hda: cs35l41: Do not allow uninitialised variables to be freed
ALSA: hda: cs35l41: Only add SPI CS GPIO if SPI is enabled in kernel
sound/pci/hda/cs35l41_hda_property.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 ALSA: hda: cs35l41: Do not allow uninitialised variables to be freed
Initialise the variables to NULL so that they cannot be uninitialised when devm_kfree is called.
Found by static analysis.
--- sound/pci/hda/cs35l41_hda_property.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
sound/pci/hda/cs35l41_hda_property.c +4 -4
@@ -77,10 +77,10 @@ static const struct cs35l41_config cs35l41_config_table[] = {static int cs35l41_add_gpios (struct cs35l41_hda *cs35l41,struct device *physdev,int reset_gpio,int spkid_gpio,int cs_gpio_index,int num_amps) { -struct acpi_gpio_mapping *gpio_mapping; -struct acpi_gpio_params *reset_gpio_params; -struct acpi_gpio_params *spkid_gpio_params; -struct acpi_gpio_params *cs_gpio_params; +struct acpi_gpio_mapping *gpio_mapping =NULL ; +struct acpi_gpio_params *reset_gpio_params =NULL ; +struct acpi_gpio_params *spkid_gpio_params =NULL ; +struct acpi_gpio_params *cs_gpio_params =NULL ;unsigned int num_entries =0 ;unsigned int reset_index, spkid_index, csgpio_index;int i;
Signature · 1 line
2.34.1
PATCH 2/2 ALSA: hda: cs35l41: Only add SPI CS GPIO if SPI is enabled in kernel
In reply to Stefan BindingIf CONFIG_SPI is not set in the kernel, there is no point in trying to set the chip selects. We can selectively compile it.
--- sound/pci/hda/cs35l41_hda_property.c | 3 +++ 1 file changed, 3 insertions(+)
sound/pci/hda/cs35l41_hda_property.c +3 -0
@@ -210,6 +210,8 @@ static int generic_dsd_config(struct cs35l41_hda *cs35l41, struct device *physdeif (cfg->bus ==SPI ) { cs35l41->index = id; + +#if IS_ENABLED (CONFIG_SPI )/* * Manually set the Chip Select for the second amp <cs_gpio_index> in the node. * This is only supported for systems with 2 amps, since we cannot expand the
@@ -249,6 +251,7 @@ static int generic_dsd_config(struct cs35l41_hda *cs35l41, struct device *physde spi_setup(spi); } } +#endif }else {if (cfg->num_amps >2 )/*
Signature · 1 line
2.34.1
Re: [PATCH v1 2/2] ALSA: hda: cs35l41: Only add SPI CS GPIO if SPI is enabled in kernel
Quoted 3 lines · Stefan Binding
If
CONFIG_SPIis not set in the kernel, there is no point in trying to set the chip selects. We can selectively compile it.
I guess it should with IS_REACHABLE() instead of IS_ENABLED()? It can be still CONFIG_SPI=m while CONFIG_SND_HDA_*=y.
thanks,
Takashi
Quoted 34 lines
Fixes 8c4c216db8fb ("ALSA: hda: cs35l41: Add config table to support many laptops without _DSD")Reported-by kernel test robot <[email protected]>Signed-off-by Stefan Binding <[email protected]>--- sound/pci/hda/cs35l41_hda_property.c | 3 +++ 1 file changed, 3 insertions(+)sound/pci/hda/cs35l41_hda_property.c +3
-0@@ -210,6 +210,8 @@ static int generic_dsd_config(struct cs35l41_hda *cs35l41, struct device *physdeif (cfg->bus ==SPI ) { cs35l41->index = id; + +#if IS_ENABLED (CONFIG_SPI )/* * Manually set the Chip Select for the second amp <cs_gpio_index> in the node. * This is only supported for systems with 2 amps, since we cannot expand the @@ -249,6 +251,7 @@ static int generic_dsd_config(struct cs35l41_hda *cs35l41, struct device *physde spi_setup(spi); } } +#endif }else {if (cfg->num_amps >2 )/* Signature · 1 line
2.34.1
Re: [PATCH v1 2/2] ALSA: hda: cs35l41: Only add SPI CS GPIO if SPI is enabled in kernel
Quoted 9 lines · Takashi Iwai
Quoted 3 lines · Stefan Binding
If
CONFIG_SPIis not set in the kernel, there is no point in trying to set the chip selects. We can selectively compile it.I guess it should with
IS_REACHABLE()instead ofIS_ENABLED()? It can be stillCONFIG_SPI=mwhile CONFIG_SND_HDA_*=y.
In anyway, I applied the patches as is for now, as it should work in most cases. Let's see whether the use of IS_REACHABLE() is required.
thanks,
Takashi