Re: [PATCH] SOUND: OSS sequencer should be initialized aftersnd_seq_system_client_init

From: Jaswinder Singh Rajput
Date: Mon Jul 20 2009 - 01:03:25 EST


Hello Catalin,

On Sun, 2009-07-19 at 23:19 +0100, Catalin Marinas wrote:
> On Sun, 2009-07-19 at 21:58 +0530, Jaswinder Singh Rajput wrote:
> > [PATCH] SOUND: OSS sequencer should be initialized after snd_seq_system_client_init
> >
> > When build SND_SEQUENCER in kernel then OSS sequencer(alsa_seq_oss_init)
> > is initialized before System (snd_seq_system_client_init) which leads to
> > memory leak :
>
> Thanks for investigating this. I haven't looked at the code in detail
> but I find it a bit weird that initialisation order fixes the memory
> leak. Shouldn't the memory allocation logic change slightly to avoid the
> leak as well (that's in case someone manually inserts the modules in the
> wrong order)?
>

No, you cannot change the order of modules because
'insmod sound/core/seq/oss/snd-seq-oss.ko' need following symbols :

[ 385.258252] snd_seq_oss: Unknown symbol snd_seq_kernel_client_enqueue
[ 385.258435] snd_seq_oss: Unknown symbol snd_seq_set_queue_tempo
[ 385.258639] snd_seq_oss: Unknown symbol snd_seq_delete_kernel_client
[ 385.258751] snd_seq_oss: Unknown symbol snd_seq_autoload_lock
[ 385.258871] snd_seq_oss: Unknown symbol snd_seq_kernel_client_dispatch
[ 385.259782] snd_seq_oss: Unknown symbol snd_seq_kernel_client_enqueue_blocking
[ 385.260191] snd_seq_oss: Unknown symbol snd_seq_autoload_unlock
[ 385.260418] snd_seq_oss: Unknown symbol snd_seq_device_register_driver
[ 385.260537] snd_seq_oss: Unknown symbol snd_midi_event_free
[ 385.260701] snd_seq_oss: Unknown symbol snd_midi_event_no_status
[ 385.260964] snd_seq_oss: Unknown symbol snd_use_lock_sync_helper
[ 385.261469] snd_seq_oss: Unknown symbol snd_seq_device_unregister_driver
[ 385.261659] snd_seq_oss: Unknown symbol snd_seq_event_port_detach
[ 385.261768] snd_seq_oss: Unknown symbol snd_midi_event_new
[ 385.261910] snd_seq_oss: Unknown symbol snd_midi_event_decode
[ 385.262067] snd_seq_oss: Unknown symbol snd_seq_create_kernel_client
[ 385.262233] snd_seq_oss: Unknown symbol snd_seq_kernel_client_write_poll
[ 385.262432] snd_seq_oss: Unknown symbol snd_midi_event_encode_byte
[ 385.262963] snd_seq_oss: Unknown symbol snd_seq_kernel_client_ctl

And we can get these symbols in this way :

1. insmod sound/core/seq/snd-seq-device.ko
[ 385.258751] snd_seq_oss: Unknown symbol snd_seq_autoload_lock
[ 385.260191] snd_seq_oss: Unknown symbol snd_seq_autoload_unlock
[ 385.260418] snd_seq_oss: Unknown symbol snd_seq_device_register_driver
[ 385.261469] snd_seq_oss: Unknown symbol snd_seq_device_unregister_driver

2. insmod sound/core/seq/snd-seq.ko
[ 385.258252] snd_seq_oss: Unknown symbol snd_seq_kernel_client_enqueue
[ 385.258435] snd_seq_oss: Unknown symbol snd_seq_set_queue_tempo
[ 385.258639] snd_seq_oss: Unknown symbol snd_seq_delete_kernel_client
[ 385.258871] snd_seq_oss: Unknown symbol snd_seq_kernel_client_dispatch
[ 385.259782] snd_seq_oss: Unknown symbol snd_seq_kernel_client_enqueue_blocking
[ 385.260964] snd_seq_oss: Unknown symbol snd_use_lock_sync_helper
[ 385.261659] snd_seq_oss: Unknown symbol snd_seq_event_port_detach
[ 385.262067] snd_seq_oss: Unknown symbol snd_seq_create_kernel_client
[ 385.262233] snd_seq_oss: Unknown symbol snd_seq_kernel_client_write_poll
[ 385.262963] snd_seq_oss: Unknown symbol snd_seq_kernel_client_ctl

3. insmod sound/core/seq/snd-seq-midi-event.ko
[ 385.260701] snd_seq_oss: Unknown symbol snd_midi_event_no_status
[ 385.260537] snd_seq_oss: Unknown symbol snd_midi_event_free
[ 385.261768] snd_seq_oss: Unknown symbol snd_midi_event_new
[ 385.261910] snd_seq_oss: Unknown symbol snd_midi_event_decode
[ 385.262432] snd_seq_oss: Unknown symbol snd_midi_event_encode_byte

So the only order is :

1. insmod sound/core/seq/snd-seq-device.ko
2. insmod sound/core/seq/snd-seq.ko
3. insmod sound/core/seq/snd-seq-midi-event.ko
4. insmod sound/core/seq/oss/snd-seq-oss.ko

which is correct, if you change the order like we was getting in
build-in kernel, which leads to improper initialization and memory leak
was the side-effect.

Thanks,
--
JSR

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/