Skip to content

Commit

Permalink
ALSA: add private_data to struct snd_jack
Browse files Browse the repository at this point in the history
Added private_data and private_free fields to struct snd_jack so that
the caller can assign the data.  It'll be helpful for avoiding the
double-free of the jack instance.

Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Apr 14, 2009
1 parent 577c9c4 commit 9d59065
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/sound/jack.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ struct snd_jack {
int type;
const char *id;
char name[100];
void *private_data;
void (*private_free)(struct snd_jack *);
};

#ifdef CONFIG_SND_JACK
Expand Down
3 changes: 3 additions & 0 deletions sound/core/jack.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ static int snd_jack_dev_free(struct snd_device *device)
{
struct snd_jack *jack = device->device_data;

if (jack->private_free)
jack->private_free(jack);

/* If the input device is registered with the input subsystem
* then we need to use a different deallocator. */
if (jack->registered)
Expand Down

0 comments on commit 9d59065

Please sign in to comment.