Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4343284pxu; Mon, 12 Oct 2020 16:56:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTaRAkAsACuzsaeddASJEacpP3Hl6rExjdidE87IxR1i2ato+JyfBLIr+3jNcf0fnR+wlS X-Received: by 2002:a05:6402:1c04:: with SMTP id ck4mr17313515edb.274.1602546963554; Mon, 12 Oct 2020 16:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602546963; cv=none; d=google.com; s=arc-20160816; b=K1MG98rHQsJlXlnFk2nRs0wk0Ze1re7yzB4I/r9/vLBWsIwCGm2C6zKjdohC5O9JbJ GKwVqN7eiZHtXRAV7IXM0A8rF7MMjRMC/sCKCl4AokDhqnJloniH27JBMX33qQDNxhFW UxH3Cyuda/hxt5FHk8wAn/MS6wfi994bjvIqX8bCtcCuP7FUXoC4FuYYR1qoBPgBThfP naR2By5chSWuPFa4WsUzNYy1TqImyOQpBi9C4Wnv09hksJsV9zTUTP7yJ3IytRRVm8Xh NHcljWEOFkNVhsX+iI8FUlFhJ/6S/nVQU3jrFegMuvtOLCCCLcUi1aOHLC2ESy14GxiI uvNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JykMBbcMoVKq/MhfHzw3F3e71+Xezv4fUvPi5PZufFU=; b=CatBmCk/F/9moLbItfzIYxOEYP6NGVxodpM0gqupp9LkNW35ilh9aodE+77y3hguCq 6CtM5e/7jBWSg+QfLCb8PXgVsyuFUsYJBAz1vxXp1jATuGzrcioJQrr65vPLmgSK8O0u 5wlRmnEZ34kJ8xOnM47/1g+1gavWOWtHuylSqu/NqFUehx8KxTLstVgWi3go9ZgxYOrr r1OP4ubXCSylQnS6x57bDt1pfo3sYAHUuqR2508i0mAgsavtjdvDocOiaweTbZkNJE7+ Crzv0I0VsaB6bWofeKpjNAv1CdaK1ZF2g/H5JLAatZkdwgSqKdehRrxGMiEOww5xM7FE zlSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VTUc6gzx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h2si13075733ejo.1.2020.10.12.16.55.40; Mon, 12 Oct 2020 16:56:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VTUc6gzx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390467AbgJLNzM (ORCPT + 99 others); Mon, 12 Oct 2020 09:55:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:47942 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389657AbgJLNpl (ORCPT ); Mon, 12 Oct 2020 09:45:41 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 846242225F; Mon, 12 Oct 2020 13:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510267; bh=ECMisNL/3ISLyOzerwuAYHR8RzFjOxrIyD7RWOoAV9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VTUc6gzxvinD5Os9euFLgwgOLzwiVSlYErNdFIbJ3w6rdpkAdWdMFY2IKNEUCguA5 6O9wUncEurlQb4pwPfy/G/ISS1uuI4OPpqJ1VyFtYKM3/6bj5YFTP5QNj9199Gg4M9 apr47XIRSjG441Z2T+ijxHfOEGt9b842qXsKczf4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chaitanya Kulkarni , Logan Gunthorpe , Christoph Hellwig Subject: [PATCH 5.8 026/124] nvme-core: put ctrl ref when module ref get fail Date: Mon, 12 Oct 2020 15:30:30 +0200 Message-Id: <20201012133148.115584432@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012133146.834528783@linuxfoundation.org> References: <20201012133146.834528783@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chaitanya Kulkarni commit 4bab69093044ca81f394bd0780be1b71c5a4d308 upstream. When try_module_get() fails in the nvme_dev_open() it returns without releasing the ctrl reference which was taken earlier. Put the ctrl reference which is taken before calling the try_module_get() in the error return code path. Fixes: 52a3974feb1a "nvme-core: get/put ctrl and transport module in nvme_dev_open/release()" Signed-off-by: Chaitanya Kulkarni Reviewed-by: Logan Gunthorpe Signed-off-by: Christoph Hellwig Signed-off-by: Greg Kroah-Hartman --- drivers/nvme/host/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -3061,8 +3061,10 @@ static int nvme_dev_open(struct inode *i } nvme_get_ctrl(ctrl); - if (!try_module_get(ctrl->ops->module)) + if (!try_module_get(ctrl->ops->module)) { + nvme_put_ctrl(ctrl); return -EINVAL; + } file->private_data = ctrl; return 0;