Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp180269imd; Wed, 31 Oct 2018 16:56:41 -0700 (PDT) X-Google-Smtp-Source: AJdET5dzEuUIOvCgf1JTt2+snrJx2LqL2PttyBzkIY8JLczRi48wkwHFNPpZlHzdxbzrLhg2VUK9 X-Received: by 2002:a17:902:5a2:: with SMTP id f31-v6mr5322659plf.320.1541030200996; Wed, 31 Oct 2018 16:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541030200; cv=none; d=google.com; s=arc-20160816; b=WY+jN3HyXfxr2FMkv7eYM0xda7TuHUxvtarObYb/tLCY+X9fsO+uqJTiRWpdZbS0hB 3SkVBDOTi7TATo3totpE+RVyXYuSLvJiD4F02mpY3MorZECaqtQVfuacQVaqUDBV3Ug9 Dnl9r0eP90EGWYE6E57hFU05nOeuxcBMCz0zSvRhQicLpRZxV1pMELTZk+8YTAXoqMs+ X3Pj+5O635XGaV19aq+Ba+yoUMWFMe5HUqyQFVTgrKYw0UKZS4tuRubZff6B9C1Z0gV1 doCz1Zic954lp8JKnUJg/fxQUBhOT2gU+nM+HOOGT/fPN183AT0obG+iVq+5I9Yr/YK+ 9xeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=QB98PQEui5BNYhhUI/4b+EyKjQiYBo+wFW1kMyS7egY=; b=E6kZ7tB98SBd74mW/wafLzaN5yl4UrjInabKsy1y8up9VRUafd96GhntOgytJ7s0yi uHHRu9fp40g2z1nx4lau9nGRbOQFPMZxQWkX9v7s7GL8HZ2jhVN8FsuMbv4eQo2eahET SC01rdT0Y91WQqfuFMaBC/a0L3nQ/Af08Gf3uylHyKePSBBIImeOZO2/pqD56Qw29bEC 6ZVtmbpGkpb6uDuvtmIWItAeXH3kjSvOQ765pRBX10q8/IGK9ksIfd5RYDVT9lefyE+Y bbo/KhNU4rm8nLI+YpPaivdnY5Qzv3ejskMhkANAdm/SX0lAKFi4L/8zrVQKIgpHLWCk tq2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EVK0ymRM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q82-v6si13739369pfk.266.2018.10.31.16.56.26; Wed, 31 Oct 2018 16:56:40 -0700 (PDT) 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=EVK0ymRM; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727944AbeKAIzS (ORCPT + 99 others); Thu, 1 Nov 2018 04:55:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:52610 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726549AbeKAIF6 (ORCPT ); Thu, 1 Nov 2018 04:05:58 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 08C3520821; Wed, 31 Oct 2018 23:05:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027148; bh=mlnNognbhobDyzNnJrdaa+++B29jwSgnl0YcoSO2r6k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EVK0ymRMinQJ0sDm8iQoSGLh8bBlfLTaQzpcbMMio4aRJffU+LKBovVel0qFQRm0p F8of6/4iTdcTak7MIJ7ohL5ZVvew2ZfGarFeDxzcgCKL1nrHdZHYSYjHudWT4PWuGD Cw0hwtm0/sa18J9cDC2DTZyZq9/sxmyW5U70KC0M= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Omar Sandoval , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL 4.19 006/146] ataflop: fix error handling during setup Date: Wed, 31 Oct 2018 19:03:21 -0400 Message-Id: <20181031230541.28822-6-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 dfb2c2622e5a..822e3060d834 100644 --- a/drivers/block/ataflop.c +++ b/drivers/block/ataflop.c @@ -1935,6 +1935,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) @@ -1966,10 +1971,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); } @@ -1984,13 +1985,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; -- 2.17.1