Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3440503imu; Sun, 11 Nov 2018 15:09:08 -0800 (PST) X-Google-Smtp-Source: AJdET5dGVgSKwbR6B1cbQ1Y6svTNBaf59tu3BdnLLR3hu78AioFLFzjwICZ+OsY/MBkXZE5blK2K X-Received: by 2002:a63:9809:: with SMTP id q9mr15431069pgd.109.1541977748255; Sun, 11 Nov 2018 15:09:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541977748; cv=none; d=google.com; s=arc-20160816; b=cJDdH+3glzMPwiimTv/rmLH4UU7nr9UhzQyOy8XzFaFb/SHHPa/TIB15GLiRmyIe7D 17tw9omaxKINTmM6zd2FZA2RntvAvKtpR2yM2fpdip2tJl3KTV0zACrAl6Ie5zFW7NFo b0YP4JqSPSj+/E9Mr/AH2jyFDLRf7an2KJJIWiHXYyqLR7swhXkddYbz+NLpbEn6j8Ei nkOCYrNNTuC1n/R8NXFI9Hj2cVkZaI2aQms+IDY0pTXrAM67haO4uEw0DDrZ2U+0m7At pHQXlpPVAv194GR4ZN9yYr283Q0DolHxHAbVe0qXoBZ/7sNIizxFWkaB1VoCscuydy4G ntcA== 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=aKCIrobT+WOWj8kmmLg0UQaGDW69HPkdYBqVb26usz0=; b=dWmwPQ7l77lqHwGaAvSSg/fGndx8b+45Y7aKm05523KRsZh5ynTdS92U4Nk2JAbZLu nTQkHilrWGpzQ3ecAuAKSVXCBfcRii8h+/5fua61PvoCftGqBo0Ju/A2FTJZRrhRrdL/ hpncg+AB/81iG17Y8u8sVmuWN2duC7xVjCOtCgyt+azwYCPDJO59ED/33j4THCt85Cz1 T3R7w9Qy1b0rjLP5yqTvXqSdxWVoPwxUuYVAbJijkj+7LUoNnuBGt1trJCG86cnEJe8p ap4Uhl5BUzvcGjmMNTzMq5BUyyUEs9g8ei1ZFpOjp8s4GkF3HVwin+DEkSPe15/TdxEA 3PlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o8ZsaxLI; 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 l11-v6si14579129pgm.102.2018.11.11.15.08.53; Sun, 11 Nov 2018 15:09:08 -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=o8ZsaxLI; 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 S2390319AbeKLIWJ (ORCPT + 99 others); Mon, 12 Nov 2018 03:22:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:51268 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390277AbeKLIWI (ORCPT ); Mon, 12 Nov 2018 03:22:08 -0500 Received: from localhost (unknown [206.108.79.134]) (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 314D62243E; Sun, 11 Nov 2018 22:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975531; bh=cLvwUZ0hnD/wJMuYRtYuVzMsPH9ZiorbeP7K/3yax8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o8ZsaxLItjGi3oQ8R1UBlWwP5lGdcI8Oh6hcRszoPvTjB2VWJpNUQu4CtYSjhKfh+ b5wpQzpJ9B1tzr27O1Vpw/zsz7XpBVkLBsn5Mrmhmp4BTB0dMQjKej2fbKbCx0oZxD XOWCz87U32v6w2StXE5eFIZX3p57j1xSMUhBe2XA= 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 040/222] ataflop: fix error handling during setup Date: Sun, 11 Nov 2018 14:22:17 -0800 Message-Id: <20181111221651.772967715@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221647.665769131@linuxfoundation.org> References: <20181111221647.665769131@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Omar Sandoval [ Upstream commit 71327f547ee3a46ec5c39fdbbd268401b2578d0e ] 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 Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/block/ataflop.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -1935,6 +1935,11 @@ static int __init atari_floppy_init (voi 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) @@ -1966,10 +1971,6 @@ static int __init atari_floppy_init (voi 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); } @@ -1984,13 +1985,17 @@ static int __init atari_floppy_init (voi 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;