Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4414648pxa; Mon, 10 Aug 2020 08:32:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxtUQF5yNoES9q0TJ5qXoniNs4jJeP1ubAu5ECHjpJ3YYz1d58j2ug+mOAyVewTWUvT0ow X-Received: by 2002:aa7:c88f:: with SMTP id p15mr21886095eds.33.1597073572783; Mon, 10 Aug 2020 08:32:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597073572; cv=none; d=google.com; s=arc-20160816; b=IpiWPjGMG/WOCHpCiYY/ElZPPQG1ed45tG4RCwdkwfxTGHhf18TV6+MTpPB777Y6ZY E6XgXXGib4VLOzhKEAFvcRuVoMK2EvM1DlQ17jNCRWa1JN+91HSYght62u1+aJzSNk34 vtinllkMjbXJbHXVXui3kgPQm7PBhz3A9PnFhDSHTQ/8sFMR59ojcC4dxknMT8YBq/XB RQ3zyL1hKZ/Tw47414ZY6RZC+QunEjWd8aRLqiDgaLmMqOkJk4z2g16jURYjCeH5GG7R PsiMHz1T0BEOqet6yAU3WcTbQ3Deodn88e/M9hXxVNrLDkrqjdLDxiVvb7cnSmxsPMbh YZLQ== 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=57YsT/DAx5LP64UVQQGrr3rBGGomi5oeNZCQGbeyB0Q=; b=K3oeXxsdl2f/ycKrDGnrs9bn0l6RYet8vq/6zLXoYstSO6G8iTC5DjVuT443jh33tk kERHvHOQGWM7Z5C8OdOGhNXNnSdfyTYk6PybgNwGTzFtUwLl6vq1Ffxei72Lk9tXQ78V AtunPNk2IRfKyeWhyNgF+a9mWCaPko00QWVzlRZt5yHyJbbUFMo/sO9A15qMbW3dD5vg B2VnmsVHcFlE7H358HcpCF4aNLRZEgKlzAm8Nf+6tGg5l+IivkWGJRHOzjTEPeQoBWA1 1yNuAwkQc4/BQ+nVTS9tYlxZuAtqd6R26PmNgTbxT5nqtwzV11R11CoH4QbwVZc7BU/Y q3lA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SnoB2x53; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si10557610edx.271.2020.08.10.08.32.29; Mon, 10 Aug 2020 08:32:52 -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=SnoB2x53; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729170AbgHJPbG (ORCPT + 99 others); Mon, 10 Aug 2020 11:31:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:38254 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728661AbgHJPbD (ORCPT ); Mon, 10 Aug 2020 11:31:03 -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 7FB69207FF; Mon, 10 Aug 2020 15:31:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073463; bh=tYygRtCCqYPvmOEPK2ySkKydBlf7eZqGSMwcgYZbsb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SnoB2x53wtEBhH7zGS1ktboosmHONliEvHZMXxermW0684mHY42SyLIAEuv9JycZJ acEro8tE0sA6DHQ+LRxoHBP9SgaavQKDKo5mhnhpGX9CNTSEis5vgKFZupQCJLWiLx qgHrIUTJNs2hFOvWiCPXaJz+8+9MuHOSK1SnIRSs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Martyna Szapar , Andrew Bowers , Jeff Kirsher , Jesse Brandeburg Subject: [PATCH 4.19 47/48] i40e: Memory leak in i40e_config_iwarp_qvlist Date: Mon, 10 Aug 2020 17:22:09 +0200 Message-Id: <20200810151806.541597863@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151804.199494191@linuxfoundation.org> References: <20200810151804.199494191@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 From: Martyna Szapar [ Upstream commit 0b63644602cfcbac849f7ea49272a39e90fa95eb ] Added freeing the old allocation of vf->qvlist_info in function i40e_config_iwarp_qvlist before overwriting it with the new allocation. Fixes: e3219ce6a7754 ("i40e: Add support for client interface for IWARP driver") Signed-off-by: Martyna Szapar Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Jesse Brandeburg Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 23 +++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) --- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c @@ -441,6 +441,7 @@ static int i40e_config_iwarp_qvlist(stru u32 v_idx, i, reg_idx, reg; u32 next_q_idx, next_q_type; u32 msix_vf, size; + int ret = 0; msix_vf = pf->hw.func_caps.num_msix_vectors_vf; @@ -449,16 +450,19 @@ static int i40e_config_iwarp_qvlist(stru "Incorrect number of iwarp vectors %u. Maximum %u allowed.\n", qvlist_info->num_vectors, msix_vf); - goto err; + ret = -EINVAL; + goto err_out; } size = sizeof(struct virtchnl_iwarp_qvlist_info) + (sizeof(struct virtchnl_iwarp_qv_info) * (qvlist_info->num_vectors - 1)); + kfree(vf->qvlist_info); vf->qvlist_info = kzalloc(size, GFP_KERNEL); - if (!vf->qvlist_info) - return -ENOMEM; - + if (!vf->qvlist_info) { + ret = -ENOMEM; + goto err_out; + } vf->qvlist_info->num_vectors = qvlist_info->num_vectors; msix_vf = pf->hw.func_caps.num_msix_vectors_vf; @@ -469,8 +473,10 @@ static int i40e_config_iwarp_qvlist(stru v_idx = qv_info->v_idx; /* Validate vector id belongs to this vf */ - if (!i40e_vc_isvalid_vector_id(vf, v_idx)) - goto err; + if (!i40e_vc_isvalid_vector_id(vf, v_idx)) { + ret = -EINVAL; + goto err_free; + } vf->qvlist_info->qv_info[i] = *qv_info; @@ -512,10 +518,11 @@ static int i40e_config_iwarp_qvlist(stru } return 0; -err: +err_free: kfree(vf->qvlist_info); vf->qvlist_info = NULL; - return -EINVAL; +err_out: + return ret; } /**