drivers/cdrom/gdrom.c: fix device number leak
authorLibo Chen <clbchenlibo.chen@huawei.com>
Wed, 3 Jul 2013 22:01:11 +0000 (15:01 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 3 Jul 2013 23:07:25 +0000 (16:07 -0700)
Without this patch, gdrom_major will leak when gd.cd_info alloc fails.

Signed-off-by: Libo Chen <libo.chen@huawei.com>
Cc: Jens Axboe <axboe@kernel.dk>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/cdrom/gdrom.c

index 4afcb65cc62397466aee5f8272051e197a9c9fb1..5980cb9af857891491baee6026efe16cb84694de 100644 (file)
@@ -830,9 +830,9 @@ probe_fail_cdrom_register:
        del_gendisk(gd.disk);
 probe_fail_no_disk:
        kfree(gd.cd_info);
+probe_fail_no_mem:
        unregister_blkdev(gdrom_major, GDROM_DEV_NAME);
        gdrom_major = 0;
-probe_fail_no_mem:
        pr_warning("Probe failed - error is 0x%X\n", err);
        return err;
 }