Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6027408ybc; Wed, 27 Nov 2019 13:39:32 -0800 (PST) X-Google-Smtp-Source: APXvYqwsO34I6PJXD3T45l+uZ1QArYskH14mqahfvWhzMw5Cw2aN6I0NGc+n1pGQbtps9nCslR2A X-Received: by 2002:a17:906:f28a:: with SMTP id gu10mr8900717ejb.107.1574890772828; Wed, 27 Nov 2019 13:39:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890772; cv=none; d=google.com; s=arc-20160816; b=x/ThCfKE5kDnq2C9DbWtqnzHj9xR6Cutgnci96h6vQdwCMmdVEH5tsYAgM6vJrgSEn lkdp4A+YMVgfjXh8pi3BNbQ7qprQ9YkyrakptlRJ3O+DL4JQVl6PhylMEf+MxJrHmf+v MngXgXaQmYu+GpReMXI2PbHrLn/Y7s4euhXFJJ6yuvdqwP9xJmk0tvVK9f01GuoBawEK 8PodQYoe1T56Hpc97PvRJ6lcJwKlyuLHB+wvJGhQdme1wG6hj/VEQ24lS9sKr1ePKPPQ mp9EONe2alij3lAzHxLd6waVbjI3dn6arix6TbIFS9eux1lU6G6nvLQk8FjTrFL3DUCW YxiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=W+nzIofUCftC8GOhYrBvDfWy5sQ5kTbXG+gqw2FRnhc=; b=d06ZuakZ5eicRnI8s20tXfTnChm6jipypN8oAoXE7n2X1qiXTaeNT+bB0AOIkKj0Kk dzmgqRwFxouVKNNnZYZNd0i2q4lIAZV+M7eSs+vKZbLC6d5oyDr5rV2KKGqOcHSmANVD pEbbGgy6UnNUTZdfpWZtXF7Md/ZGTPT7yfPPpmyfSJ+di44LN6Kar3pNaEzpyGvCAsvJ u8zhry992te/gzGfM4hPZ2bXheP48Z+eMfBu14tk+/8fQk1ZKMcZNjZxFNbU+Fm8UbUk dSS3KyAsp8eZZfL1Wbt7i9x8m0yeSkQCcx5gwRun7Hr+V+3MpfaiVoKTqtD5nDncreVy hUdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XRGScoYe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si13115202edk.210.2019.11.27.13.39.09; Wed, 27 Nov 2019 13:39:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XRGScoYe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729522AbfK0Urg (ORCPT + 99 others); Wed, 27 Nov 2019 15:47:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:60448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730012AbfK0Urd (ORCPT ); Wed, 27 Nov 2019 15:47:33 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 64AFC217F9; Wed, 27 Nov 2019 20:47:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887652; bh=4qWikL+dgIycA9R60kt5tym208RHB/8vxf181e199fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XRGScoYe/2pFRY/PX5sqZexowk9j8/cax2xejw+nkDXqdWmGKDG9JF+7w2/zhHU7X jd1kYRwjnj75NJll0e4xqMAn93Bcow0I+0PYRqflG3bn+e48bCAvB3rCo3aKAL1cbp uCzTLJEgnba5B6/fshQVX8TAU5Pk7ebnZqN79zFo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Omar Sandoval , Jens Axboe , Sasha Levin Subject: [PATCH 4.14 041/211] amiflop: clean up on errors during setup Date: Wed, 27 Nov 2019 21:29:34 +0100 Message-Id: <20191127203056.704728241@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203049.431810767@linuxfoundation.org> References: <20191127203049.431810767@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Omar Sandoval [ Upstream commit 53d0f8dbde89cf6c862c7a62e00c6123e02cba41 ] The error handling in fd_probe_drives() doesn't clean up at all. Fix it up in preparation for converting to blk-mq. While we're here, get rid of the commented out amiga_floppy_remove(). Signed-off-by: Omar Sandoval Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/amiflop.c | 84 ++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 49908c74bfcb0..b0e8d8364876b 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -1699,11 +1699,41 @@ static const struct block_device_operations floppy_fops = { .check_events = amiga_check_events, }; +static struct gendisk *fd_alloc_disk(int drive) +{ + struct gendisk *disk; + + disk = alloc_disk(1); + if (!disk) + goto out; + + disk->queue = blk_init_queue(do_fd_request, &amiflop_lock); + if (IS_ERR(disk->queue)) { + disk->queue = NULL; + goto out_put_disk; + } + + unit[drive].trackbuf = kmalloc(FLOPPY_MAX_SECTORS * 512, GFP_KERNEL); + if (!unit[drive].trackbuf) + goto out_cleanup_queue; + + return disk; + +out_cleanup_queue: + blk_cleanup_queue(disk->queue); + disk->queue = NULL; +out_put_disk: + put_disk(disk); +out: + unit[drive].type->code = FD_NODRIVE; + return NULL; +} + static int __init fd_probe_drives(void) { int drive,drives,nomem; - printk(KERN_INFO "FD: probing units\nfound "); + pr_info("FD: probing units\nfound"); drives=0; nomem=0; for(drive=0;drivecode == FD_NODRIVE) continue; - disk = alloc_disk(1); + + disk = fd_alloc_disk(drive); if (!disk) { - unit[drive].type->code = FD_NODRIVE; + pr_cont(" no mem for fd%d", drive); + nomem = 1; continue; } unit[drive].gendisk = disk; - - disk->queue = blk_init_queue(do_fd_request, &amiflop_lock); - if (!disk->queue) { - unit[drive].type->code = FD_NODRIVE; - continue; - } - drives++; - if ((unit[drive].trackbuf = kmalloc(FLOPPY_MAX_SECTORS * 512, GFP_KERNEL)) == NULL) { - printk("no mem for "); - unit[drive].type = &drive_types[num_dr_types - 1]; /* FD_NODRIVE */ - drives--; - nomem = 1; - } - printk("fd%d ",drive); + + pr_cont(" fd%d",drive); disk->major = FLOPPY_MAJOR; disk->first_minor = drive; disk->fops = &floppy_fops; @@ -1742,11 +1762,11 @@ static int __init fd_probe_drives(void) } if ((drives > 0) || (nomem == 0)) { if (drives == 0) - printk("no drives"); - printk("\n"); + pr_cont(" no drives"); + pr_cont("\n"); return drives; } - printk("\n"); + pr_cont("\n"); return -ENOMEM; } @@ -1837,30 +1857,6 @@ static int __init amiga_floppy_probe(struct platform_device *pdev) return ret; } -#if 0 /* not safe to unload */ -static int __exit amiga_floppy_remove(struct platform_device *pdev) -{ - int i; - - for( i = 0; i < FD_MAX_UNITS; i++) { - if (unit[i].type->code != FD_NODRIVE) { - struct request_queue *q = unit[i].gendisk->queue; - del_gendisk(unit[i].gendisk); - put_disk(unit[i].gendisk); - kfree(unit[i].trackbuf); - if (q) - blk_cleanup_queue(q); - } - } - blk_unregister_region(MKDEV(FLOPPY_MAJOR, 0), 256); - free_irq(IRQ_AMIGA_CIAA_TB, NULL); - free_irq(IRQ_AMIGA_DSKBLK, NULL); - custom.dmacon = DMAF_DISK; /* disable DMA */ - amiga_chip_free(raw_buf); - unregister_blkdev(FLOPPY_MAJOR, "fd"); -} -#endif - static struct platform_driver amiga_floppy_driver = { .driver = { .name = "amiga-floppy", -- 2.20.1