Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1598693pxj; Wed, 19 May 2021 09:26:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVENwCg/BjHCiEIBy9pBB2yTxlEft7suLyYpBsF7sV/fXJF70loB52YbX2JYvjvcO2dpC/ X-Received: by 2002:a17:907:b09:: with SMTP id h9mr13111697ejl.430.1621441590822; Wed, 19 May 2021 09:26:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621441590; cv=none; d=google.com; s=arc-20160816; b=X+pOAz0+fI7O/EwqoSKCkC12TjARkpm4KVtsXLn2LDd3EUvEVP9frpmlmKabg41I8x WeItX1zmeTGo0vomwkW+y/Cix0wYK2q8McgtnZT1pDn2pJXWE0a297wZFsja9CRCOPhS 1j3U+zQalOq/u7MJ2CxOwAa7cCpliyq3BsUySD15XrHHq0uWSntfoiseEUJNfbNIElPt FEmlXas2MpbrIBgy9FplfU1fO41bRo6z6k+RjjqzKyWw1AATbnBIUtkPwB0YHaGXdA+T zaOu9RpFF/JTRHlYIu/5q+4CEUUls83MLLcSCciKL1zjlS6ZBVXBl+NaHj15gP/CtsD4 6PaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=QcFgFiUgMDt8QFvw+8imNWgzHpFLAkaEsd8wurelMPw=; b=vGwCxVesQ72rwyUU5BrbLBezD7euEdv7B4gYzHfEY/eullV8zx7/+Qrzutfe9zMe9r 7IbQBt4OPNEDaEfauMrsnYwwUN7OrXKbeoOOrBTVbjbsvubqCpYTAcjPQNpzZXcztk9a /unts4rBALeSum3qymMGFEqUzOtvN4vHxFDxAkHJHaVgDBBXxTvZLcwkM3P6QOlk3Hke KZLeiur2wOp4TM54pkL29wvBOhAoHW35HSqvqprIqYvgPdNLIx23HaKfPNIhA9vuLWWp rVtzfxSNM79MmHoM8wr4Th/pO0zRWVe0veztCCc2PPv1xv5/Js4u7kk6Y1g13TOn5lLA CuEA== ARC-Authentication-Results: i=1; mx.google.com; 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=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o11si4752935edc.497.2021.05.19.09.26.06; Wed, 19 May 2021 09:26:30 -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; 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=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346847AbhERIWV (ORCPT + 99 others); Tue, 18 May 2021 04:22:21 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:3015 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346279AbhERIWU (ORCPT ); Tue, 18 May 2021 04:22:20 -0400 Received: from dggems706-chm.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Fkpmj6lyPzlg3D; Tue, 18 May 2021 16:18:45 +0800 (CST) Received: from dggpeml500019.china.huawei.com (7.185.36.137) by dggems706-chm.china.huawei.com (10.3.19.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 18 May 2021 16:20:49 +0800 Received: from huawei.com (10.175.124.27) by dggpeml500019.china.huawei.com (7.185.36.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 18 May 2021 16:20:48 +0800 From: Wu Bo To: , , , , , , CC: , Subject: [PATCH] nvmet: fix memory leak on nvmet_alloc_ctrl() Date: Tue, 18 May 2021 16:46:38 +0800 Message-ID: <1621327598-542045-1-git-send-email-wubo40@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500019.china.huawei.com (7.185.36.137) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wu Bo When cntlid_min is greater than cntlid_max, goto wrong label, should be goto out_free_sqs label. Otherwise there is a memory leak problem on the nvmet_alloc_ctrl function(). Fixes: 94a39d61f80f ("nvmet: make ctrl-id configurable") Fixes: 6d65aeab7bf6e ("nvmet: remove unused ctrl->cqs") Signed-off-by: Wu Bo --- drivers/nvme/target/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index 25cc2ee8de3f..1853db38b682 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -1372,7 +1372,7 @@ u16 nvmet_alloc_ctrl(const char *subsysnqn, const char *hostnqn, goto out_free_changed_ns_list; if (subsys->cntlid_min > subsys->cntlid_max) - goto out_free_changed_ns_list; + goto out_free_sqs; ret = ida_simple_get(&cntlid_ida, subsys->cntlid_min, subsys->cntlid_max, -- 2.30.0