Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3542757pxj; Mon, 24 May 2021 09:02:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytmu7jj53nlU7GfUCc6rFBcn2XVwqJ2Jl0GBaH2bAeGgB7fvDnw1yvGkdFP9MbvQxDI6iQ X-Received: by 2002:a05:6602:cd:: with SMTP id z13mr16326630ioe.199.1621872131449; Mon, 24 May 2021 09:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872131; cv=none; d=google.com; s=arc-20160816; b=uzSwLGEp5ylMjcoI89vpzrl+Le6M9ct0V8arlCnAPx/BUPjfTteaIhfu97vHaKEgwA GgNUr1SZTqmQN/aATMHWqsNkhv+TMZo0MJlzn6lJzNjEuoWJhy1zyXEMr+8fSLF9dg5o tF6ua4YHGHRL+4LzNlOjD+B7lyUeKIBrSv+HVbY1b/TT1ZiCq07MCOaqInUH9uQSvaVl eCbyBLBfPIwIlrfz+H3OL7THKaK2cdBVCRwiX2/QQHlkPphoNIZpCrSfB/OmoadVqBZ5 0W46d4Sfu/crZfszrCdBWD0VNRpAehbmK5qNPcUV5mBoYYcRijFojwd51l8IvYMZMdyu MQ2g== 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=gtSO3iUU2dswQekjp5lJFOWh20IfUZYIx+rtsBusRJw=; b=vOEIm3X5JP30+5HgwQij6aRfucdqiVAfr5+NvCFtZJDMyh3XcFBf/IlUQVr2hLaqz2 uczZ/ik8Ipisv+xWap5vgrD8qhgLeYfqPWqn3x7NAw8Y1SlaHgft9KHQ8uJcJ+mKuRyM tcKs7e2bV4lfRPT9d6k5eqNAApIXB7pn6gq0lP4Pt+CSZDA/6culU6IraHeq+KrUlgqi fyKfrdgRGjzfSaplScxZbe1SLW5dusioTd6tPH+0TxwRVDIQyOz2p+lHO0xw26kKPcoN vVe2jeizK9o4NlmmrYQ8SSqpaNmZcfUk+As1fu+fC7E/FmfPFSsqmWAZ4fEBT0YOxzvc 3cbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=neIxO5nx; 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=pass (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 o18si3505539ils.28.2021.05.24.09.01.55; Mon, 24 May 2021 09:02:11 -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=@linuxfoundation.org header.s=korg header.b=neIxO5nx; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236071AbhEXQB3 (ORCPT + 99 others); Mon, 24 May 2021 12:01:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:38730 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234411AbhEXPwQ (ORCPT ); Mon, 24 May 2021 11:52:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7684D61626; Mon, 24 May 2021 15:39:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870744; bh=fMSXUdR7wbsC5swJDfCnN+SJNX5Vn2BTqpfmIwvqvK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=neIxO5nxpZVJ5rY4boJjNPVl3I02XrQwQaeqqC+rzaJUum+73mjXvRBNCl9+KwXmg galX0bmEJBWIstGGH9JbOQmAd/Aqy9oD00zhaJeXS5s8mbms5hYGBAEgLwbVa10uQ2 iztzjzdEV45HgkIj4qau2n4zwVNRpPJLGJy6uoDU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wu Bo , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.10 015/104] nvme-loop: fix memory leak in nvme_loop_create_ctrl() Date: Mon, 24 May 2021 17:25:10 +0200 Message-Id: <20210524152333.331152784@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152332.844251980@linuxfoundation.org> References: <20210524152332.844251980@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: Wu Bo [ Upstream commit 03504e3b54cc8118cc26c064e60a0b00c2308708 ] When creating loop ctrl in nvme_loop_create_ctrl(), if nvme_init_ctrl() fails, the loop ctrl should be freed before jumping to the "out" label. Fixes: 3a85a5de29ea ("nvme-loop: add a NVMe loopback host driver") Signed-off-by: Wu Bo Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- drivers/nvme/target/loop.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c index f6d81239be21..b869b686e962 100644 --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c @@ -578,8 +578,10 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev, ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_loop_ctrl_ops, 0 /* no quirks, we're perfect! */); - if (ret) + if (ret) { + kfree(ctrl); goto out; + } if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) WARN_ON_ONCE(1); -- 2.30.2