Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3020295imu; Mon, 19 Nov 2018 09:27:00 -0800 (PST) X-Google-Smtp-Source: AJdET5dPyj+CZFUcj+sC6ef/Chl3Wbd5NEAs4LCSgNnbNy6LBSJ+D31Raxc44UpAfmiLtgrGuMN8 X-Received: by 2002:a65:4683:: with SMTP id h3mr19978850pgr.225.1542648419986; Mon, 19 Nov 2018 09:26:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542648419; cv=none; d=google.com; s=arc-20160816; b=qM7dknXtS5vrCsawS2Lh/736Xl6Ql+/Mx+Oy3UmHWKrVRGXyXoSuaGCXN7jBB56G+T 7xCvw3OaGI4JMzQrYmiZs7aHdaRRPfR1mgTDyb30OBxhb347vcuZGm+oTCBWtgOaBwrb S5CSe2MTQiOnZKwqKzlGz8de2JT0g5oJznMfcxEdOZGsPM/YV4btVL9j/W9qWtOi0QrA bbGc87AYPhTwYeFooLd55ojb5kw+LltcO2KZZWzzrW/8+f+4UhrtGADIJd1Cuosimz14 5RCbra0iAEdCgtXNLpVDtiaxJ5asqalfuB9hMun5UeWi67nJVsFbZ1UKUx14uYwUO1CK kDKA== 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=84PKnZYvusDVuXptMzx7GT76kCxgWcrnMjao0X2zovs=; b=YwV02x46APAkmbw3l0SwI0mP01L1+8Esy4Rzfnsw+6o3Nfv2gvzwjVoPWYnA5cqJTe ar0T0oulJ9QOnAWFMRDwFOa1/j3Uy/6Kw+WEtnqdH+Jpx7xyP/qS4f1lmwsc7yqlAJp5 o62ULHJBVOyWf7fi84zEsS1xHUM2xam8iQTlOkaEKgp0L3/tAtg/v4MBTHbK+KcAOCaA vVfLzXBHzwTr1H0A7gV2TZS2sj9iCKX9OLyFLHMpQGj0xBLIerMW1lYSNSvWnwiQvSFm DyzRB92KU4nNIGMDL9y2WK72GP+qpSv0dth+O6014azT0WflXtcsNMISgrU2ARvZzu/R MQHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iK1immQQ; 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 v4-v6si39887414plp.247.2018.11.19.09.26.31; Mon, 19 Nov 2018 09:26:59 -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=iK1immQQ; 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 S2404289AbeKTDUt (ORCPT + 99 others); Mon, 19 Nov 2018 22:20:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:60284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390603AbeKTDUr (ORCPT ); Mon, 19 Nov 2018 22:20:47 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 53140208E3; Mon, 19 Nov 2018 16:56:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542646592; bh=DJfbPe9ZalAzV8bp3eMJzVRyJt78XXzfSFnEZWOttC4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iK1immQQrcAt8kLJmfQAJbzkg/alflrHnMycsSkE+VPactOeiGSRjCtZvk6OkgB40 sWxlBbj2kDV0siSULQhBg+EMRmtoAx4G5HDoATf5sltdFlZPZvPehPwSXHjCU/NRHp HIKeOOXn4hdoggniil/WISN8GMcy+Se8qlwN9ud4= 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.4 017/160] ataflop: fix error handling during setup Date: Mon, 19 Nov 2018 17:27:36 +0100 Message-Id: <20181119162632.083371287@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162630.031306128@linuxfoundation.org> References: <20181119162630.031306128@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.4-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 @@ -1933,6 +1933,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) @@ -1964,10 +1969,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); } @@ -1982,13 +1983,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;