From patchwork Thu Oct 11 19:20:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10637235 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 7B1EB112B for ; Thu, 11 Oct 2018 19:21:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D0152C04B for ; Thu, 11 Oct 2018 19:21:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B4EB2C069; Thu, 11 Oct 2018 19:21:08 +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 0D33A2C05A for ; Thu, 11 Oct 2018 19:21:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729732AbeJLCtl (ORCPT ); Thu, 11 Oct 2018 22:49:41 -0400 Received: from mail-pf1-f176.google.com ([209.85.210.176]:41177 "EHLO mail-pf1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726918AbeJLCtl (ORCPT ); Thu, 11 Oct 2018 22:49:41 -0400 Received: by mail-pf1-f176.google.com with SMTP id m77-v6so4892153pfi.8 for ; Thu, 11 Oct 2018 12:21:06 -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=gfQLUwmrz95bOSfLv5dmgG6r4GmkIIcwT6cwra7eUUzQMTJCVvsrgEwBGvzvn2YSw5 xHFpYg1RlLg3jJGLzZbTqUREOx3/VtdaYcjRwlgzzt9j8w2u6LjMAHhAl+w/G0wU683C ZIuU+aYVjBnCAJwUb18A+TUG4KjpEd2QIaxIBuQ++r+1+mFX7EOis9FYf+FjVaP98goy kQs+a70vDCSlFAhJfxvzM63pxdGQsLDKkE2X/eRtIkRbM1goRKlxyqfAZPXKTUa9is9M 5P3AmUXASsmD43xHeIvlS1bW0MX0kZik9bT4uWYBies+6WNfw2TvsMrIkuFKIkMpmgpS 838w== 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=KAfMVgtzcNy1mA/IKBNjGitkF6bePbYiaWrisHlXx0n6nmMVjTaDLdeEBK4/W5t8By QZnEiqVN0BwgJygO7vtRMC/mIwcB5dz60dqLAGo7RdZAm24XV1Bt+dnfcZ2LC7+l+Xw0 RzwgRWZ38/mxxPkndHrje16OKi0xaeUA08Cd/bVPaZ9iF754j17fP7wVYiFBt3miXvm9 7ACzFbX8P0NnzKfBPvx0sLhwjELfe/9gDZHnpXCQm45Zl+tQRUGeviUPE91bBqf0fo3B O9M4SvOaECmflhW9np7wqRlb++mKnq/liuqwG5ce9h2JSb33UljdqenRD+Gi9cm93Ve+ YBpA== X-Gm-Message-State: ABuFfoixcqZTegl8bdGWIXf1h4qdkhuvXBOVN1Yu0UOQWwQGg2suGw2A sI0tdv4yNob5iSw1Hk1yyl4bOtXDSLo= X-Google-Smtp-Source: ACcGV63L99wLt0r7e0LS/1YkFjHTp29YIyk0MvFO9ziIY8yxEeSd5BeE8iEkVTMOo9ScV8IKKv9SLw== X-Received: by 2002:a62:9f11:: with SMTP id g17-v6mr2816167pfe.144.1539285665800; Thu, 11 Oct 2018 12:21:05 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::5:2383]) by smtp.gmail.com with ESMTPSA id y24-v6sm44378838pfi.24.2018.10.11.12.21.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 12:21:05 -0700 (PDT) From: Omar Sandoval To: linux-block@vger.kernel.org Cc: Jens Axboe , kernel-team@fb.com Subject: [PATCH v2 09/11] ataflop: fix error handling during setup Date: Thu, 11 Oct 2018 12:20:49 -0700 Message-Id: <14c0c51ba6a2778285f5764dca8ffd26575ac691.1539284959.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;