Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp885755yba; Thu, 18 Apr 2019 11:11:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDXauekBCVlCadKr9jwTB3bb3GBAYAnBHa+xD6uvqBWu2sjnVW+4PiEnayrEr5xDxD3btK X-Received: by 2002:a63:6804:: with SMTP id d4mr43465154pgc.240.1555611112943; Thu, 18 Apr 2019 11:11:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611112; cv=none; d=google.com; s=arc-20160816; b=qaI9EJPjgzYjbL6aS2ATE8IuDBcgJu1ge3R49qOEMpA3kE+CF/pIrdtHF3zyZrGF8y wCaKWe3ixZq/KPJy+jmwAkpzdzeRex++sgkoWsSq2VjKpPFlbIaGGJh/DPQemEIsvGw8 Zy3e9p/nt/XUKQ582x0NdnqQ6qiGMv+YBL2SXvt3KPD+pSUbh2mQepv0pvfV/PUm1LPO HMvnzdYPvfmgd4DoVzzXKEkb7wJrDO4wDUaz4FuzN6331KGqjnsthMHNoMV3hK9+aRTL N79O+AWwBCKKF8+piN3XxTbeiqlx+LJOBh4AznwB96EQJcpLPMKoyE3bGvX2z56iyiQM enpA== 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=2oesNiQYCQ/5U962TjQLlgZMQYx7FpCIEw9KJ0NTAnc=; b=F2rgfe8izdT8sDBeFkXgNXDdWdb7gC4fGdtHmX/kAtAqCJFNtKQXzVqL/e2tl+nojo 0wZR/pyXreSh3L2ZinugHoT+LTXq03gb3Gor7jveD9UQ/rbUJon+1EcVJlR/PJMvaObh YJAPpHjWx1oV/O28njpObRxPz4mK2m5SAcpSECMw5jl9vZHDi7NgAb9fkpU8QEmkptaW piDdpiTnwl4JhDkUWn24QY7y5ztWd8GDcXN3aO6aSitPSg8SaOWjKZ3a8OFQdjXyTFQI YOfsB9+I3Wnc/hgb14QngWDKOfOGzYFCW0FIFp3JALSotrHySWE1l6A3gVb36MqJ1Ame m3Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sK5zBVXA; 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 t3si2674914plq.181.2019.04.18.11.11.37; Thu, 18 Apr 2019 11:11:52 -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=sK5zBVXA; 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 S2404038AbfDRSJ4 (ORCPT + 99 others); Thu, 18 Apr 2019 14:09:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:41598 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403986AbfDRSJx (ORCPT ); Thu, 18 Apr 2019 14:09:53 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 40923206B6; Thu, 18 Apr 2019 18:09:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610992; bh=dvRYEgICU7B9lvD98/PMOD4n2rvOT2dfBGAP+bmKAY4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sK5zBVXArCQIojSDG6uzRfcQMt+Nbjr3ffqOhNkgusddMaIP4z5jZV951uQHMmyEX bS028yyXSxrICqpQTzLI1uLTCCsgDBJu1JynGlXeYfW+wOjsqnsEjfdV59vXAWAoYs 6gTX685UDwdY5NGaDeDndXR6lKLeg269KWtrO1u8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Randy Dunlap , Jens Axboe , Sasha Levin Subject: [PATCH 5.0 18/93] paride/pf: cleanup queues when detection fails Date: Thu, 18 Apr 2019 19:56:56 +0200 Message-Id: <20190418160438.663257972@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160436.781762249@linuxfoundation.org> References: <20190418160436.781762249@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 6ce59025f1182125e75c8d121daf44056b65dd1f ] The driver allocates queues for all the units it potentially supports. But if we fail to detect any drives, then we fail loading the module without cleaning up those queues. This is now evident with the switch to blk-mq, though the bug has been there forever as far as I can tell. Also fix cleanup through regular module exit. Reported-by: Randy Dunlap Tested-by: Randy Dunlap Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/block/paride/pf.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c index e92e7a8eeeb2..103b617cdc31 100644 --- a/drivers/block/paride/pf.c +++ b/drivers/block/paride/pf.c @@ -761,8 +761,12 @@ static int pf_detect(void) return 0; printk("%s: No ATAPI disk detected\n", name); - for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) + for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) { + blk_cleanup_queue(pf->disk->queue); + pf->disk->queue = NULL; + blk_mq_free_tag_set(&pf->tag_set); put_disk(pf->disk); + } pi_unregister_driver(par_drv); return -1; } @@ -1047,13 +1051,15 @@ static void __exit pf_exit(void) int unit; unregister_blkdev(major, name); for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) { - if (!pf->present) - continue; - del_gendisk(pf->disk); + if (pf->present) + del_gendisk(pf->disk); + blk_cleanup_queue(pf->disk->queue); blk_mq_free_tag_set(&pf->tag_set); put_disk(pf->disk); - pi_release(pf->pi); + + if (pf->present) + pi_release(pf->pi); } } -- 2.19.1