From patchwork Thu Oct 11 18:30:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10637103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDEBD17E3 for ; Thu, 11 Oct 2018 18:30:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E05EB2BEC1 for ; Thu, 11 Oct 2018 18:30:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D51C42BEEA; Thu, 11 Oct 2018 18:30:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A7C72BEE9 for ; Thu, 11 Oct 2018 18:30:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729152AbeJLB7L (ORCPT ); Thu, 11 Oct 2018 21:59:11 -0400 Received: from mail-pg1-f179.google.com ([209.85.215.179]:43932 "EHLO mail-pg1-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729175AbeJLB7L (ORCPT ); Thu, 11 Oct 2018 21:59:11 -0400 Received: by mail-pg1-f179.google.com with SMTP id 80-v6so4561915pgh.10 for ; Thu, 11 Oct 2018 11:30:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/+ISgGhJwtAGzKowvLRcks0rVA+K+dVjkOrn5EYUabs=; b=I2MajMEK2gEDIEMTOWVhKHcP4NpuD27vhNHJX/JLU4FjmHrsEw3M9/SBJGQSFbB96n bcXtpxYcuDObxf+B/eqnUdvmQb7An5zY5Sy2BTQf1HjimeUy0YCPoAfjqAkWonDTg4FN JMPyVUzhZDsbo9gyKglZkTNcxCXEKRIiuatzOu8tBmAA9imsSYmZniq3RHxf0BYmcJvS lOzMnGV/IIi9KETJzzft6l2T9Sdt49tDESAnUEg5f8ZrBXrPPOxr948a32n7OzbgddhP U/xssnJ/hn07HDihjBg/YQ3ws/jSPQngL7F3O2v8yKjS3TL+wawTTu3W+NW1ewj4p6EC cQeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/+ISgGhJwtAGzKowvLRcks0rVA+K+dVjkOrn5EYUabs=; b=HG+3OoJQDomdAbEiCkyJeVvi8biW41aELSkW1cIhUMVxqnP3S/RBIhs1Qh9s3+S3Uf ji2DIz3HrdypkB9yzy2rQ8xCiiIkmEF6V+D9MDIGlgUItKtPfp8jm18z8iVjbBjH/iV9 OgB6Z8RReJrPuiU/mQnjvMjctjQ4QiuurqU5J9xwhv628LikXm77FU73et0FQdea4bHr HLrL10gScNZwZL6heWic7O4vvAb+1l3Jlno1PZt96mdgnRmgCAKUjqb6a5b1exe90K1g TuEroFzzyjTMhdAP7YCMWmElv2hrnFcj9hEZDCdvUgXdu7suadrrOeMYcJ/waJotk5hn QYZQ== X-Gm-Message-State: ABuFfoh9A/SMP7BFXFhcjkwyYA2GGJBQ4FundIt/FZAgINSJmw9FhTWR uiAon+Z4pVg6SDQd1o/dJJu29pVdedw= X-Google-Smtp-Source: ACcGV60l4MLvKpOIfnU/spyPjlVN74PlGo5HCy6ZqwVeVAYG7zz7HczbjV6c2bCFfNuefH17HpNcyA== X-Received: by 2002:a63:184a:: with SMTP id 10-v6mr2362728pgy.81.1539282645949; Thu, 11 Oct 2018 11:30:45 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::5:2383]) by smtp.gmail.com with ESMTPSA id o2-v6sm57514640pfj.57.2018.10.11.11.30.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 11:30:45 -0700 (PDT) From: Omar Sandoval To: linux-block@vger.kernel.org Cc: Jens Axboe , kernel-team@fb.com Subject: [PATCH 10/13] ataflop: fix error handling during setup Date: Thu, 11 Oct 2018 11:30:20 -0700 Message-Id: <22892297ed4f1b951dfb06c0c20752cc6956cb1a.1539282366.git.osandov@fb.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval Move queue allocation next to disk allocation to fix a couple of issues: - If add_disk() hasn't been called, we should clear disk->queue before calling put_disk(). - If we fail to allocate a request queue, we still need to put all of the disks, not just the ones that we allocated queues for. Signed-off-by: Omar Sandoval --- drivers/block/ataflop.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c index 17df631c5d85..0144d598ac47 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -2014,6 +2014,11 @@ static int __init atari_floppy_init (void) unit[i].disk = alloc_disk(1); if (!unit[i].disk) goto Enomem; + + unit[i].disk->queue = blk_init_queue(do_fd_request, + &ataflop_lock); + if (!unit[i].disk->queue) + goto Enomem; } if (UseTrackbuffer < 0) @@ -2045,10 +2050,6 @@ static int __init atari_floppy_init (void) sprintf(unit[i].disk->disk_name, "fd%d", i); unit[i].disk->fops = &floppy_fops; unit[i].disk->private_data = &unit[i]; - unit[i].disk->queue = blk_init_queue(do_fd_request, - &ataflop_lock); - if (!unit[i].disk->queue) - goto Enomem; set_capacity(unit[i].disk, MAX_DISK_SIZE * 2); add_disk(unit[i].disk); } @@ -2063,13 +2064,17 @@ static int __init atari_floppy_init (void) return 0; Enomem: - while (i--) { - struct request_queue *q = unit[i].disk->queue; + do { + struct gendisk *disk = unit[i].disk; - put_disk(unit[i].disk); - if (q) - blk_cleanup_queue(q); - } + if (disk) { + if (disk->queue) { + blk_cleanup_queue(disk->queue); + disk->queue = NULL; + } + put_disk(unit[i].disk); + } + } while (i--); unregister_blkdev(FLOPPY_MAJOR, "fd"); return -ENOMEM;