Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3116278imu; Mon, 19 Nov 2018 10:52:04 -0800 (PST) X-Google-Smtp-Source: AJdET5clG7V82Uu9CeHDWzVN/6+HYnhbjZLd0aHffM5ZDWGPgBDj6fJyp40tO7Kk4ihKGgIHlhRh X-Received: by 2002:a65:48c4:: with SMTP id o4mr20605644pgs.371.1542653524259; Mon, 19 Nov 2018 10:52:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542653524; cv=none; d=google.com; s=arc-20160816; b=vGo9LeHgxy7ZwcOxqthDMOSKCch/TnjLYHxrbRx3Ob7hEA2Xt7H8Wifn+YRFdhF3f2 ida++LV0BBmn6n4a1ZfwxE6OcH9USCYgvmarozk6IzZiZW6hKiWjivmpysZAONpDEhbS 0kAZOrVdBs4jL1sKO7sBIFqAmk2PZHxNBE17l9cSdOE9TTvACsrwPThkuARQDirkM16A Z5PxkMWV3GYDQnnxkbj2lm3HCyrjoxEtxC5EJfGxtGLXGTYkdfDZBjmrZ8PF2Y0+75Cs 0zAVw1Xhvyih29i5s/Dqnm1q2JnzJv/CPktd8I8rG+90v8uw0zKWAr5VFwemD7eGZ/Oy j57Q== 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=9PDdtaTnleQqvBPY+v3BqD8EB8+f3bYmtYMTqtePK48=; b=a7+HhOJwbp1kGJwo5W8Qj4LhpfVs+HiMLAStbU4E436IwfUkj4Qjfj2CWp4LQLW8f7 1dxxjfu4JJ8nXwEwmIE3hkg74KqhXJc3JPOeqzyyjEgLutMWZP2QrIjgZDVq0YkpVUJe YDlmzF8SneZfA5zP+MEDzIcz39xXo+VdVC59X53pCyMi1McWeRsUNj54KElpP2okyhpJ iKOwbeFWas0e/pTMe34GTTXMjbX/Dld7jpySG0tarHT1rKg1b4EFqbEYUAO6zOlYNlQ0 qyLagYFZUWfeB9P/OixXYHFA9y++m7MuAcg7+QhUNrQycNr2eDDtD1eooG6N5vmSVzmX +e7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=InmP0cjt; 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 204si28071259pfu.273.2018.11.19.10.51.49; Mon, 19 Nov 2018 10:52:04 -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=InmP0cjt; 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 S2406207AbeKTD1e (ORCPT + 99 others); Mon, 19 Nov 2018 22:27:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:41582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405390AbeKTD1d (ORCPT ); Mon, 19 Nov 2018 22:27:33 -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 B326C21508; Mon, 19 Nov 2018 17:03:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542646996; bh=Pilb8+AbYg8LEMZG1iSgZKWXCbzXNbeKAvlpGfG3Qqs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=InmP0cjtv5sliMOYBLCTerDlss3Lp6iGUdTgt3TS4d6ZfzjWSn7QIdS6yGjgbY+k7 U4tXTZypsEQk3hi02+vMXuGC+s+1xLUGBD2uacTY/CdZCCxsB1UISCTr8EShbYU/SE yxChV10au0nvNI3ht9jjfwgdxR8m9LMG7EwMUXxE= 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 3.18 11/90] ataflop: fix error handling during setup Date: Mon, 19 Nov 2018 17:28:53 +0100 Message-Id: <20181119162622.637315099@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162620.585061184@linuxfoundation.org> References: <20181119162620.585061184@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 3.18-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;