ALSA: firewire: use managed-resource of fw unit device for private data
At present, private data of each driver in ALSA firewire stack is allocated/freed by kernel slab allocator for corresponding unit on IEEE 1394 bus. In this case, resource-managed slab allocator is available to release memory object automatically just before releasing device structure for the unit. This idea can prevent runtime from memory leak due to programming mistakes. This commit uses the allocator for the private data. These drivers already use reference counter to maintain lifetime of device structure for the unit by a pair of fw_unit_get()/fw_unit_put(). The private data is safely released in a callback of 'struct snd_card.private_free(). Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Este cometimento está contido em:

cometido por
Takashi Iwai

ascendente
4a9a72e0db
cometimento
366a20d7a7
@@ -32,10 +32,8 @@ static void ff_free(struct snd_ff *ff)
|
||||
snd_ff_stream_destroy_duplex(ff);
|
||||
snd_ff_transaction_unregister(ff);
|
||||
|
||||
fw_unit_put(ff->unit);
|
||||
|
||||
mutex_destroy(&ff->mutex);
|
||||
kfree(ff);
|
||||
fw_unit_put(ff->unit);
|
||||
}
|
||||
|
||||
static void ff_card_free(struct snd_card *card)
|
||||
@@ -102,11 +100,9 @@ static int snd_ff_probe(struct fw_unit *unit,
|
||||
{
|
||||
struct snd_ff *ff;
|
||||
|
||||
ff = kzalloc(sizeof(struct snd_ff), GFP_KERNEL);
|
||||
if (ff == NULL)
|
||||
ff = devm_kzalloc(&unit->device, sizeof(struct snd_ff), GFP_KERNEL);
|
||||
if (!ff)
|
||||
return -ENOMEM;
|
||||
|
||||
/* initialize myself */
|
||||
ff->unit = fw_unit_get(unit);
|
||||
dev_set_drvdata(&unit->device, ff);
|
||||
|
||||
|
Criar uma nova questão referindo esta
Bloquear um utilizador