[alsa-devel] [PATCH 03/14] ALSA: Add a helper to initialize device

Takashi Iwai tiwai at suse.de
Mon Feb 2 14:40:01 CET 2015


At Mon, 02 Feb 2015 14:31:40 +0100,
Lars-Peter Clausen wrote:
> 
> On 02/02/2015 11:24 AM, Takashi Iwai wrote:
> > diff --git a/sound/core/init.c b/sound/core/init.c
> > index 074875d68c15..2f730efe97b6 100644
> > --- a/sound/core/init.c
> > +++ b/sound/core/init.c
> > @@ -157,6 +157,25 @@ static int get_slot_from_bitmask(int mask, int (*check)(struct module *, int),
> >   	return mask; /* unchanged */
> >   }
> >
> > +static void default_release(struct device *dev)
> > +{
> > +}
> 
> A empty release callback is pretty much always wrong and typically causes 
> use-after-free bugs. It might be correct in this case, but there should at 
> least be a comment explaining why it is correct.

Right, a bit more explanation would be better: we have already
dev_free callback in snd_device chain, and this would do almost all
job.  That's why we can leave empty as default there.

> And on the long run things 
> should probably be re-factored to do all memory freeing in a subdevice 
> specific release function.

This patchset is one step toward the simplification, indeed.

But, what do you have in mind when you write "a subsystem specific
release function"?


thanks,

Takashi


More information about the Alsa-devel mailing list