ASoC: Series of loose fixes

Amadeusz Sławiński <amade@asmblr.net> says:

Following current fashion of poking code with LLM to see what issues it
finds. Some are minor, other more likely to cause some real issues like
the one with snd_soc_limit_volume() returning positive value, while
callers do simple if (ret) check.

Link: https://patch.msgid.link/20261014200608.118770-1-amade@asmblr.net
This commit is contained in:
Mark Brown 2026-10-15 23:08:08 +01:00
commit f500b6437f
No known key found for this signature in database
GPG Key ID: 2FEF73B0B3D03889
8 changed files with 40 additions and 17 deletions

View File

@ -432,7 +432,7 @@ int snd_soc_component_compr_set_metadata(struct snd_compr_stream *cstream,
int snd_soc_component_compr_get_metadata(struct snd_compr_stream *cstream,
struct snd_compr_metadata *metadata);
int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
snd_pcm_uframes_t snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream);
int snd_soc_pcm_component_ioctl(struct snd_pcm_substream *substream,
unsigned int cmd, void *arg);
int snd_soc_pcm_component_sync_stop(struct snd_pcm_substream *substream);

View File

@ -69,7 +69,7 @@ static int snd_soc_ac97_gpio_direction_in(struct gpio_chip *chip,
{
struct snd_soc_component *component = gpio_to_component(chip);
dev_dbg(component->dev, "set gpio %d to output\n", offset);
dev_dbg(component->dev, "set gpio %d to input\n", offset);
return snd_soc_component_update_bits(component, AC97_GPIO_CFG,
1 << offset, 1 << offset);
}
@ -241,10 +241,12 @@ struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
ret = snd_soc_ac97_init_gpio(ac97, component);
if (ret)
goto err_put_device;
goto err_del_device;
return ac97;
err_del_device:
device_del(&ac97->dev);
err_put_device:
put_device(&ac97->dev);
return ERR_PTR(ret);

View File

@ -70,6 +70,7 @@ static void test_snd_soc_card_get_kcontrol(struct kunit *test)
static int soc_card_test_case_init(struct kunit *test)
{
struct soc_card_test_priv *priv;
struct device *dev;
int ret;
priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
@ -82,8 +83,10 @@ static int soc_card_test_case_init(struct kunit *test)
if (!priv->card)
return -ENOMEM;
priv->card_dev = kunit_device_register(test, "sound-soc-card-test");
priv->card_dev = get_device(priv->card_dev);
dev = kunit_device_register(test, "sound-soc-card-test");
if (IS_ERR(dev))
return PTR_ERR(dev);
priv->card_dev = get_device(dev);
if (!priv->card_dev)
return -ENODEV;

View File

@ -920,7 +920,7 @@ int snd_soc_component_test_bits(struct snd_soc_component *component,
}
EXPORT_SYMBOL_GPL(snd_soc_component_test_bits);
int snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
snd_pcm_uframes_t snd_soc_pcm_component_pointer(struct snd_pcm_substream *substream)
{
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
struct snd_soc_component *component;

View File

@ -2869,6 +2869,7 @@ static void dapm_free_path(struct snd_soc_dapm_path *path)
*/
void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w)
{
struct snd_soc_dapm_context *d;
struct snd_soc_dapm_path *p, *next_p;
enum snd_soc_dapm_direction dir;
@ -2889,6 +2890,22 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w)
dapm_debugfs_free_widget(w);
if (w->dapm) {
if (w->dapm->card) {
for_each_card_dapms(w->dapm->card, d) {
if (d->wcache_sink == w)
d->wcache_sink = NULL;
if (d->wcache_source == w)
d->wcache_source = NULL;
}
} else {
if (w->dapm->wcache_sink == w)
w->dapm->wcache_sink = NULL;
if (w->dapm->wcache_source == w)
w->dapm->wcache_source = NULL;
}
}
kfree(w->kcontrols);
kfree_const(w->name);
kfree_const(w->sname);
@ -2906,9 +2923,6 @@ static void dapm_free_widgets(struct snd_soc_dapm_context *dapm)
continue;
snd_soc_dapm_free_widget(w);
}
dapm->wcache_sink = NULL;
dapm->wcache_source = NULL;
}
static struct snd_soc_dapm_widget *dapm_find_widget(

View File

@ -161,7 +161,7 @@ int snd_soc_link_trigger(struct snd_pcm_substream *substream, int cmd,
break;
ret = soc_link_trigger(substream, cmd);
soc_link_mark_pop(rtd, startup);
soc_link_mark_pop(rtd, trigger);
}
return ret;

View File

@ -406,7 +406,7 @@ EXPORT_SYMBOL_GPL(snd_soc_put_volsw_sx);
static int snd_soc_clip_to_platform_max(struct snd_kcontrol *kctl)
{
struct soc_mixer_control *mc = (struct soc_mixer_control *)kctl->private_value;
struct snd_ctl_elem_value *uctl;
struct snd_ctl_elem_value *uctl __free(kfree) = NULL;
int ret;
if (!mc->platform_max)
@ -418,7 +418,7 @@ static int snd_soc_clip_to_platform_max(struct snd_kcontrol *kctl)
ret = kctl->get(kctl, uctl);
if (ret < 0)
goto out;
return ret;
if (uctl->value.integer.value[0] > mc->platform_max)
uctl->value.integer.value[0] = mc->platform_max;
@ -428,10 +428,10 @@ static int snd_soc_clip_to_platform_max(struct snd_kcontrol *kctl)
uctl->value.integer.value[1] = mc->platform_max;
ret = kctl->put(kctl, uctl);
if (ret < 0)
return ret;
out:
kfree(uctl);
return ret;
return 0;
}
/**

View File

@ -24,8 +24,12 @@ static struct device *test_dev;
static int snd_soc_tplg_test_init(struct kunit *test)
{
test_dev = kunit_device_register(test, "sound-soc-topology-test");
test_dev = get_device(test_dev);
struct device *dev;
dev = kunit_device_register(test, "sound-soc-topology-test");
if (IS_ERR(dev))
return PTR_ERR(dev);
test_dev = get_device(dev);
if (!test_dev)
return -ENODEV;