diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-10-16 07:05:59 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-10-30 06:07:10 -0400 |
commit | a0830dbd4e42b38aefdf3fb61ba5019a1a99ea85 (patch) | |
tree | 4dc74b708a07b56d12ed72a34d0a2e0cb8c8b9d4 /include/sound | |
parent | 888ea7d5ac6815ba16b3b3a20f665a92c7af6724 (diff) |
ALSA: Add a reference counter to card instance
For more strict protection for wild disconnections, a refcount is
introduced to the card instance, and let it up/down when an object is
referred via snd_lookup_*() in the open ops.
The free-after-last-close check is also changed to check this refcount
instead of the empty list, too.
Reported-by: Matthieu CASTET <matthieu.castet@parrot.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'include/sound')
-rw-r--r-- | include/sound/core.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/sound/core.h b/include/sound/core.h index bc056687f647..93896ad1fcdd 100644 --- a/include/sound/core.h +++ b/include/sound/core.h | |||
@@ -132,6 +132,7 @@ struct snd_card { | |||
132 | int shutdown; /* this card is going down */ | 132 | int shutdown; /* this card is going down */ |
133 | int free_on_last_close; /* free in context of file_release */ | 133 | int free_on_last_close; /* free in context of file_release */ |
134 | wait_queue_head_t shutdown_sleep; | 134 | wait_queue_head_t shutdown_sleep; |
135 | atomic_t refcount; /* refcount for disconnection */ | ||
135 | struct device *dev; /* device assigned to this card */ | 136 | struct device *dev; /* device assigned to this card */ |
136 | struct device *card_dev; /* cardX object for sysfs */ | 137 | struct device *card_dev; /* cardX object for sysfs */ |
137 | 138 | ||
@@ -189,6 +190,7 @@ struct snd_minor { | |||
189 | const struct file_operations *f_ops; /* file operations */ | 190 | const struct file_operations *f_ops; /* file operations */ |
190 | void *private_data; /* private data for f_ops->open */ | 191 | void *private_data; /* private data for f_ops->open */ |
191 | struct device *dev; /* device for sysfs */ | 192 | struct device *dev; /* device for sysfs */ |
193 | struct snd_card *card_ptr; /* assigned card instance */ | ||
192 | }; | 194 | }; |
193 | 195 | ||
194 | /* return a device pointer linked to each sound device as a parent */ | 196 | /* return a device pointer linked to each sound device as a parent */ |
@@ -295,6 +297,7 @@ int snd_card_info_done(void); | |||
295 | int snd_component_add(struct snd_card *card, const char *component); | 297 | int snd_component_add(struct snd_card *card, const char *component); |
296 | int snd_card_file_add(struct snd_card *card, struct file *file); | 298 | int snd_card_file_add(struct snd_card *card, struct file *file); |
297 | int snd_card_file_remove(struct snd_card *card, struct file *file); | 299 | int snd_card_file_remove(struct snd_card *card, struct file *file); |
300 | void snd_card_unref(struct snd_card *card); | ||
298 | 301 | ||
299 | #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr)) | 302 | #define snd_card_set_dev(card, devptr) ((card)->dev = (devptr)) |
300 | 303 | ||