kzalloc() conversion in sound/
Subsystems (2)
PATCH 1/1 kzalloc() conversion in sound/
hi,
this patch converts sound (except the oss stuff) to kzalloc usage. Compile tested with allyes config, which does not include the pcc drivers.
I believe there is a possible memory leak in sound/vx/vx_pcm.c when the kmalloc() for chip->playback_pipes is succesfull, and the one for chip->capture_pipes() fails, playback_pipes will not get free()d. ( Or the other way around ).
sound/ppc/keywest.c renamed from sound/ppc/keywest.c.orig +1 -2
@@ -65,11 +65,10 @@ static int keywest_attach_adapter(structif (strncmp (i2c_device_name (adapter),"mac-io" ,6 ))return 0 ;/* ignored */ - new_client =kmalloc (sizeof (struct i2c_client ),GFP_KERNEL ); + new_client =kzalloc (sizeof (struct i2c_client ),GFP_KERNEL );if (! new_client)return -ENOMEM ; -memset (new_client,0 ,sizeof (*new_client)); new_client->addr = keywest_ctx->addr;i2c_set_clientdata (new_client, keywest_ctx); new_client->adapter = adapter;
sound/ppc/awacs.c renamed from sound/ppc/awacs.c.orig +1 -2
@@ -801,11 +801,10 @@ snd_pmac_awacs_init(struct snd_pmac *chi chip->revision = (in_le32 (&chip->awacs->codec_stat) >>12 ) &0xf ;#ifdef PMAC_AMP_AVAIL if (chip->revision ==3 && chip->has_iic &&CHECK_CUDA_AMP ()) { -struct awacs_amp *amp =kmalloc (sizeof (*amp),GFP_KERNEL ); +struct awacs_amp *amp =kzalloc (sizeof (*amp),GFP_KERNEL );if (! amp)return -ENOMEM ; chip->mixer_data = amp; -memset (amp,0 ,sizeof (*amp)); chip->mixer_free = awacs_amp_free;awacs_amp_set_vol (amp,0 ,63 ,63 ,0 );/* mute and zero vol */ awacs_amp_set_vol (amp,1 ,63 ,63 ,0 );
sound/ppc/daca.c renamed from sound/ppc/daca.c.orig +1 -2
@@ -259,10 +259,9 @@ int __init snd_pmac_daca_init(struct sndrequest_module ("i2c-keywest" );#endif /* CONFIG_KMOD */ - mix =kmalloc (sizeof (*mix),GFP_KERNEL ); + mix =kzalloc (sizeof (*mix),GFP_KERNEL );if (! mix)return -ENOMEM ; -memset (mix,0 ,sizeof (*mix)); chip->mixer_data = mix; chip->mixer_free = daca_cleanup; mix->amp_on =1 ;/* default on */
sound/ppc/tumbler.c renamed from sound/ppc/tumbler.c.orig +1 -2
@@ -1317,10 +1317,9 @@ int __init snd_pmac_tumbler_init(structrequest_module ("i2c-keywest" );#endif /* CONFIG_KMOD */ - mix =kmalloc (sizeof (*mix),GFP_KERNEL ); + mix =kzalloc (sizeof (*mix),GFP_KERNEL );if (! mix)return -ENOMEM ; -memset (mix,0 ,sizeof (*mix)); mix->headphone_irq =-1 ; chip->mixer_data = mix;
sound/core/sgbuf.c renamed from sound/core/sgbuf.c.orig +3 -6
@@ -69,21 +69,18 @@ void *snd_malloc_sgbuf_pages(struct devi dmab->area =NULL ; dmab->addr =0 ; - dmab->private_data = sgbuf =kmalloc (sizeof (*sgbuf),GFP_KERNEL ); + dmab->private_data = sgbuf =kzalloc (sizeof (*sgbuf),GFP_KERNEL );if (! sgbuf)return NULL ; -memset (sgbuf,0 ,sizeof (*sgbuf)); sgbuf->dev = device; pages =snd_sgbuf_aligned_pages (size); sgbuf->tblsize =sgbuf_align_table (pages); - sgbuf->table =kmalloc (sizeof (*sgbuf->table) * sgbuf->tblsize,GFP_KERNEL ); + sgbuf->table =kcalloc (sgbuf->tblsize,sizeof (*sgbuf->table),GFP_KERNEL );if (! sgbuf->table) goto _failed; -memset (sgbuf->table,0 ,sizeof (*sgbuf->table) * sgbuf->tblsize); - sgbuf->page_table =kmalloc (sizeof (*sgbuf->page_table) * sgbuf->tblsize,GFP_KERNEL ); + sgbuf->page_table =kcalloc (sgbuf->tblsize,sizeof (*sgbuf->page_table),GFP_KERNEL );if (! sgbuf->page_table) goto _failed; -memset (sgbuf->page_table,0 ,sizeof (*sgbuf->page_table) * sgbuf->tblsize);/* allocate each page */ for (i =0 ; i < pages; i++) {
sound/core/seq/seq_device.c renamed from sound/core/seq/seq_device.c.orig +1 -2
@@ -372,10 +372,9 @@ static struct ops_list * create_driver(c {struct ops_list *ops; - ops =kmalloc (sizeof (*ops),GFP_KERNEL ); + ops =kzalloc (sizeof (*ops),GFP_KERNEL );if (ops ==NULL )return ops; -memset (ops,0 ,sizeof (*ops));/* set up driver entry */ strlcpy (ops->id, id,sizeof (ops->id));
sound/drivers/vx/vx_pcm.c renamed from sound/drivers/vx/vx_pcm.c.orig +2 -5
@@ -1252,14 +1252,11 @@ static int vx_init_audio_io(struct vx_co chip->audio_info = rmh.Stat[1 ];/* allocate pipes */ - chip->playback_pipes =kmalloc (sizeof (struct vx_pipe *) * chip->audio_outs,GFP_KERNEL ); - chip->capture_pipes =kmalloc (sizeof (struct vx_pipe *) * chip->audio_ins,GFP_KERNEL ); + chip->playback_pipes =kcalloc (chip->audio_outs,sizeof (struct vx_pipe *),GFP_KERNEL ); + chip->capture_pipes =kcalloc (chip->audio_ins,sizeof (struct vx_pipe *),GFP_KERNEL );if (! chip->playback_pipes || ! chip->capture_pipes)return -ENOMEM ; -memset (chip->playback_pipes,0 ,sizeof (struct vx_pipe *) * chip->audio_outs); -memset (chip->capture_pipes,0 ,sizeof (struct vx_pipe *) * chip->audio_ins); - preferred = chip->ibl.size; chip->ibl.size =0 ;vx_set_ibl (chip, &chip->ibl);/* query the info */
sound/usb/usbaudio.c renamed from sound/usb/usbaudio.c.orig +1 -2
@@ -2222,10 +2222,9 @@ static int add_audio_endpoint(struct snd }/* create a new pcm */ - as =kmalloc (sizeof (*as),GFP_KERNEL ); + as =kzalloc (sizeof (*as),GFP_KERNEL );if (! as)return -ENOMEM ; -memset (as,0 ,sizeof (*as)); as->pcm_index = chip->pcm_devs; as->chip = chip; as->fmt_type = fp->fmt_type;
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 4 lines · Eric Sesterhenn
I believe there is a possible memory leak in
sound/vx/vx_pcm.cwhen thekmalloc()forchip->playback_pipesis succesfull, and the one forchip->capture_pipes()fails,playback_pipeswill not get free()d. ( Or the other way around ).
You're right. I've sent a fix to akpm. Ditto for chelsio.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors