Re: [TRIVIAL] [patch, 2.4] drivers_sound_ad1848.c doesn't release region on error

Rusty Russell (rusty@rustcorp.com.au)
Tue, 13 Aug 2002 15:01:12 +1000


In message <1029147258.16421.123.camel@irongate.swansea.linux.org.uk> you write
:
> On Mon, 2002-08-12 at 04:35, Rusty Russell wrote:
> > [ Simple, and looks trivially correct from reading file. ]
> > From: Marcus Alanen <maalanen@ra.abo.fi>
> >
> > Doesn't check request_region and doesn't release region on failed
> > kmalloc.
>
> I don't have hardware to test this, so on the basis its not tested I'd
> say no until someone with the hardware tests it.

Can someone with an ad1848 please test this trivial patch? Preferably
test that loading the module the second time works fine?

Thanks!
Rusty.

--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

===== drivers/sound/ad1848.c 1.8 vs edited ===== --- 1.8/drivers/sound/ad1848.c Fri May 10 01:40:52 2002 +++ edited/drivers/sound/ad1848.c Sun Jul 14 18:21:20 2002 @@ -1997,7 +1997,8 @@ sprintf(dev_name, "Generic audio codec (%s)", devc->chip_name); - request_region(devc->base, 4, devc->name); + if (!request_region(devc->base, 4, devc->name)) + return -1; conf_printf2(dev_name, devc->base, devc->irq, dma_playback, dma_capture); @@ -2013,8 +2014,10 @@ } portc = (ad1848_port_info *) kmalloc(sizeof(ad1848_port_info), GFP_KERNEL); - if(portc==NULL) + if(portc==NULL) { + release_region(devc->base, 4); return -1; + } if ((my_dev = sound_install_audiodrv(AUDIO_DRIVER_VERSION, dev_name, @@ -2026,8 +2029,8 @@ dma_playback, dma_capture)) < 0) { + release_region(devc->base, 4); kfree(portc); - portc=NULL; return -1; }

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