staging: most: aim-cdev: destroy ida struct in case of exception
authorChristian Gromm <christian.gromm@microchip.com>
Mon, 22 Aug 2016 14:46:24 +0000 (16:46 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 22 Aug 2016 20:41:00 +0000 (16:41 -0400)
This patch is needed to clean up the initialized ida structure in case
the function exits with an exception.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/most/aim-cdev/cdev.c

index db6f4586bcaf4badc8b1b234d21e7ed70d6ff359..1c20ae69c5616713eb70cf5876e8623387ca2b56 100644 (file)
@@ -509,7 +509,7 @@ static int __init mod_init(void)
 
        err = alloc_chrdev_region(&aim_devno, 0, 50, "cdev");
        if (err < 0)
-               return err;
+               goto dest_ida;
        major = MAJOR(aim_devno);
 
        aim_class = class_create(THIS_MODULE, "most_cdev_aim");
@@ -527,6 +527,8 @@ dest_class:
        class_destroy(aim_class);
 free_cdev:
        unregister_chrdev_region(aim_devno, 1);
+dest_ida:
+       ida_destroy(&minor_id);
        return err;
 }