[pulseaudio-discuss] [PATCH] alsa-card: Don't free the modargs in pa_init.

Peter Meerwald pmeerw at pmeerw.net
Mon Dec 30 11:09:06 PST 2013


Hi,

> > > The modargs are in both cases (a succesfull as well as a failed module
> > > initialization) freed already in pa_done().
> > 
> > the alsa module keeps a pointer to the modargs; hence, they MUST NOT be 
> > freed in the success case
> > 
> > in the fail case, the pa_modargs_free() is redundant as you noted
> 
> It's not entirely redundant. If we jump to fail before u->modargs has
> been set, then there will be a memory leak if pa_modargs_free() isn't
> called for ma (which I assume is why you added the pa_modargs_free()
> calls there in the Coverity patch set).

holy crap, alright

so in the success case, no
pa_modargs_free(ma);
since modargs are free()'d in pa__done()

in the fail case, we rely on pa__done() as well unless m->userdata == 
NULL (this can happen due to the "ignore_dB" code), so

fail:
    if (reserve)
        pa_reserve_wrapper_unref(reserve);

    if (ma && !m->userdata)
        pa_modargs_free(ma);

    pa__done(m);

probably the better fix would be to move the following code in pa__init()
   if (pa_modargs_get_value_boolean(ma, "ignore_dB", &ignore_dB) < 0) {
        pa_log("Failed to parse ignore_dB argument.");
        goto fail;
    }
a few lines down, i.e. before
   if ((u->alsa_card_index = snd_card_get_index(u->device_id)) < 0)

any objections?

ciao, p.

-- 

Peter Meerwald
+43-664-2444418 (mobile)


More information about the pulseaudio-discuss mailing list