[media] staging: lirc_serial: Free resources on failure paths of lirc_serial_probe()
authorBen Hutchings <ben@decadent.org.uk>
Wed, 16 Nov 2011 04:52:11 +0000 (01:52 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 24 Nov 2011 20:17:30 +0000 (18:17 -0200)
Failure to allocate the I/O region leaves the IRQ allocated.
A later failure leaves them both allocated.

Reported-by: Torsten Crass <torsten.crass@eBiology.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/staging/media/lirc/lirc_serial.c

index 86376311506bb62ad2dc760c4e01aee69e92bf89..d833772ef806b95c4b4ed1faa0a09a5d1a59fced 100644 (file)
@@ -875,11 +875,14 @@ static int __devinit lirc_serial_probe(struct platform_device *dev)
                       ": or compile the serial port driver as module and\n");
                printk(KERN_WARNING LIRC_DRIVER_NAME
                       ": make sure this module is loaded first\n");
-               return -EBUSY;
+               result = -EBUSY;
+               goto exit_free_irq;
        }
 
-       if (hardware_init_port() < 0)
-               return -EINVAL;
+       if (hardware_init_port() < 0) {
+               result = -EINVAL;
+               goto exit_release_region;
+       }
 
        /* Initialize pulse/space widths */
        init_timing_params(duty_cycle, freq);
@@ -911,6 +914,16 @@ static int __devinit lirc_serial_probe(struct platform_device *dev)
 
        dprintk("Interrupt %d, port %04x obtained\n", irq, io);
        return 0;
+
+exit_release_region:
+       if (iommap != 0)
+               release_mem_region(iommap, 8 << ioshift);
+       else
+               release_region(io, 8);
+exit_free_irq:
+       free_irq(irq, (void *)&hardware);
+
+       return result;
 }
 
 static int __devexit lirc_serial_remove(struct platform_device *dev)