alsa-ucm: validate access to PA_DEVICE_PORT_DATA()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2019-12-04 19:33:01 +01:00 committed by Arun Raghavan
parent f5c02dfcd8
commit e6779ad229
3 changed files with 8 additions and 4 deletions

View file

@ -1672,6 +1672,7 @@ static int sink_set_port_cb(pa_sink *s, pa_device_port *p) {
pa_assert(u); pa_assert(u);
pa_assert(p); pa_assert(p);
pa_assert(u->mixer_handle); pa_assert(u->mixer_handle);
pa_assert(!u->ucm_context);
data = PA_DEVICE_PORT_DATA(p); data = PA_DEVICE_PORT_DATA(p);
pa_assert_se(u->mixer_path = data->path); pa_assert_se(u->mixer_path = data->path);
@ -2688,7 +2689,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
* pa_sink_suspend() between pa_sink_new() and pa_sink_put() would * pa_sink_suspend() between pa_sink_new() and pa_sink_put() would
* otherwise work, but currently pa_sink_suspend() will crash if * otherwise work, but currently pa_sink_suspend() will crash if
* pa_sink_put() hasn't been called. */ * pa_sink_put() hasn't been called. */
if (u->sink->active_port) { if (u->sink->active_port && !u->ucm_context) {
pa_alsa_port_data *port_data; pa_alsa_port_data *port_data;
port_data = PA_DEVICE_PORT_DATA(u->sink->active_port); port_data = PA_DEVICE_PORT_DATA(u->sink->active_port);

View file

@ -1519,8 +1519,6 @@ static int source_set_port_ucm_cb(pa_source *s, pa_device_port *p) {
struct userdata *u = s->userdata; struct userdata *u = s->userdata;
pa_alsa_ucm_port_data *data; pa_alsa_ucm_port_data *data;
data = PA_DEVICE_PORT_DATA(p);
pa_assert(u); pa_assert(u);
pa_assert(p); pa_assert(p);
pa_assert(u->mixer_handle); pa_assert(u->mixer_handle);
@ -1545,6 +1543,7 @@ static int source_set_port_cb(pa_source *s, pa_device_port *p) {
pa_assert(u); pa_assert(u);
pa_assert(p); pa_assert(p);
pa_assert(u->mixer_handle); pa_assert(u->mixer_handle);
pa_assert(!u->ucm_context);
data = PA_DEVICE_PORT_DATA(p); data = PA_DEVICE_PORT_DATA(p);
pa_assert_se(u->mixer_path = data->path); pa_assert_se(u->mixer_path = data->path);

View file

@ -538,6 +538,9 @@ static int hdmi_eld_changed(snd_mixer_elem_t *melem, unsigned int mask) {
if (mask == SND_CTL_EVENT_MASK_REMOVE) if (mask == SND_CTL_EVENT_MASK_REMOVE)
return 0; return 0;
if (u->use_ucm)
return 0;
p = find_port_with_eld_device(u->card->ports, device); p = find_port_with_eld_device(u->card->ports, device);
if (p == NULL) { if (p == NULL) {
pa_log_error("Invalid device changed in ALSA: %d", device); pa_log_error("Invalid device changed in ALSA: %d", device);
@ -900,7 +903,8 @@ int pa__init(pa_module *m) {
* results in an infinite loop of "fill buffer, handle underrun". To work * results in an infinite loop of "fill buffer, handle underrun". To work
* around this issue, the suspend_when_unavailable flag is used to stop * around this issue, the suspend_when_unavailable flag is used to stop
* playback when the HDMI cable is unplugged. */ * playback when the HDMI cable is unplugged. */
if (pa_safe_streq(pa_proplist_gets(data.proplist, "alsa.driver_name"), "snd_hdmi_lpe_audio")) { if (!u->use_ucm &&
pa_safe_streq(pa_proplist_gets(data.proplist, "alsa.driver_name"), "snd_hdmi_lpe_audio")) {
pa_device_port *port; pa_device_port *port;
void *state; void *state;