From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83251219301; Tue, 8 Apr 2025 11:40:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744112420; cv=none; b=fDdDcKSguWd19CzGUJJk9MCywFoHt3qLOxYaGXmAixCl6D1BhoWbgfuoM5B20HzGpXhRLq6aqJRcQgX1FdOEgvKFpUzes4ApFaLj6u4jRX61ginYx9xjXUTzt6GsmnMXu0hfz7RqgoFS3K1XKKkRdC4rD0aMtV/fHSTm0ey/a10= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744112420; c=relaxed/simple; bh=59xlMi2BIInT51bWNMoVy1ZVkPrxjUNtFrPLOxVCqmU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h1iqFXztRzda+2o/LWuDtSW7nAavG4Tl0NYVyIXTbiNFcxb8i0BIKgTA6+9virBKwuCiwfvO8PsmCQ+gzBMLTiCd2h2P/sCPDtk7Vvm9YHDvPpTrIS9Wk2Y+5mNGtVob7AY1O9aTS5NW4lRqUduXrUZrEjgF2tNQn4qo5WB9ME4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=aZHW4Pqz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="aZHW4Pqz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15D4DC4CEE5; Tue, 8 Apr 2025 11:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744112420; bh=59xlMi2BIInT51bWNMoVy1ZVkPrxjUNtFrPLOxVCqmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aZHW4PqztdbsPgqXNzkhQ6ZRPP65tsnVSpZrTTLyXIYp4eDfR6/jhqR7voTcgM7H5 EsiZwb3uhsx5A6u3wObKWfSYKnYSfpFl/OLnKPoVZInUSlgsH1Dk86vzr/K3CW39u/ QtQXPeLSbXwB+Wuk7q3AngoSqMKWyGfHiDfnK3k0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Haoxiang Li , Paolo Abeni Subject: [PATCH 5.15 062/279] qlcnic: fix memory leak issues in qlcnic_sriov_common.c Date: Tue, 8 Apr 2025 12:47:25 +0200 Message-ID: <20250408104828.022024154@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104826.319283234@linuxfoundation.org> References: <20250408104826.319283234@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Haoxiang Li commit d2b9d97e89c79c95f8b517e4fa43fd100f936acc upstream. Add qlcnic_sriov_free_vlans() in qlcnic_sriov_alloc_vlans() if any sriov_vlans fails to be allocated. Add qlcnic_sriov_free_vlans() to free the memory allocated by qlcnic_sriov_alloc_vlans() if "sriov->allowed_vlans" fails to be allocated. Fixes: 91b7282b613d ("qlcnic: Support VLAN id config.") Cc: stable@vger.kernel.org Signed-off-by: Haoxiang Li Link: https://patch.msgid.link/20250307094952.14874-1-haoxiang_li2024@163.com Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c @@ -454,8 +454,10 @@ static int qlcnic_sriov_set_guest_vlan_m num_vlans = sriov->num_allowed_vlans; sriov->allowed_vlans = kcalloc(num_vlans, sizeof(u16), GFP_KERNEL); - if (!sriov->allowed_vlans) + if (!sriov->allowed_vlans) { + qlcnic_sriov_free_vlans(adapter); return -ENOMEM; + } vlans = (u16 *)&cmd->rsp.arg[3]; for (i = 0; i < num_vlans; i++) @@ -2168,8 +2170,10 @@ int qlcnic_sriov_alloc_vlans(struct qlcn vf = &sriov->vf_info[i]; vf->sriov_vlans = kcalloc(sriov->num_allowed_vlans, sizeof(*vf->sriov_vlans), GFP_KERNEL); - if (!vf->sriov_vlans) + if (!vf->sriov_vlans) { + qlcnic_sriov_free_vlans(adapter); return -ENOMEM; + } } return 0;