block/ataflop: add error handling support for add_disk()
authorLuis Chamberlain <mcgrof@kernel.org>
Mon, 27 Sep 2021 22:03:02 +0000 (15:03 -0700)
committerJens Axboe <axboe@kernel.dk>
Mon, 18 Oct 2021 20:41:37 +0000 (14:41 -0600)
We never checked for errors on add_disk() as this function
returned void. Now that this is fixed, use the shiny new
error handling.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20210927220302.1073499-15-mcgrof@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ataflop.c

index a07cb9b79a6c6e645a88f31b9b37ba29f734696e..9bc5cce6b29accedddd97802d0fda46827b3d72d 100644 (file)
@@ -2082,7 +2082,9 @@ static int __init atari_floppy_init (void)
        for (i = 0; i < FD_MAX_UNITS; i++) {
                unit[i].track = -1;
                unit[i].flags = 0;
-               add_disk(unit[i].disk[0]);
+               ret = add_disk(unit[i].disk[0]);
+               if (ret)
+                       goto err_out_dma;
                unit[i].registered[0] = true;
        }
 
@@ -2093,6 +2095,8 @@ static int __init atari_floppy_init (void)
 
        return 0;
 
+err_out_dma:
+       atari_stram_free(DMABuffer);
 err:
        while (--i >= 0)
                atari_cleanup_floppy_disk(&unit[i]);