Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3208001pxb; Mon, 9 Nov 2020 05:37:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFFcQSny7hPPrKbWxEgPMhUdEyT4aRMZjIPCk+KgUjzJOPvSsE8t2VTILvAsG20MyIO6hs X-Received: by 2002:a05:6402:104d:: with SMTP id e13mr14949325edu.322.1604929053997; Mon, 09 Nov 2020 05:37:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604929053; cv=none; d=google.com; s=arc-20160816; b=wvoRCm9i7aMMwtGH7iuDXkDHzyDEnriP62/O9x0W7Ik0MOBKrCWe4PqGQF3/tHey5f YEO8lo6b0pyECB4cziFVZZx2MXG6QQxYSCnuK7Dk19zluA2qS/ipEwxSlXdKvxLiEnH1 +FhS50QpTpM4O3SSOA4VHSdXnFNFxyPUtAAQOIXlIF5pVJfwWdSTSUk5bQZWxD7Jg4GK 9aK2OOKxetdVSETGLm5dv3fygBZhilgXV9gopRBK8QUYFjpZBvSXF5EI6r+6zWV/PwU6 2Z8ByBg8cn71DwATR/b3noJFkh/Uy1T0b/ssI7MEO995lKXLcsuLJtIavjeHvcoZlGrw TLZA== 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=tYsEUbj79Xss19OLyfthDQKqTOKjx64ZRtCDZ7a3QZ8=; b=oGaJkbaqRVFHgLDXn5EA5dVQz3/cqflwDoXlosxZBlJ+ecHEiaE2d9FljwdcZh1rWr 2OeTkOfWCSJFMYLfR8bHwPApx4SY/iiY+eogV2FF5sX1T0/bfT32VrGZyt/G7QXWJn+O BZxHSc+0RMH409Qo3Owu1QVy2ADL/fIzjVEndHyCCNL3+6MO1RwQ+1DPjKEA8qUXDp1d 1H+lRK9V27FeAzbh5K37q6oRQHABTphXod2BG065qOr+CCeL3z5KCpQK4urkJvWdaoTr pu2TKMNtfRbKk3HxwZt+cBfsSWLOJ0MdiL95ku9MHO4Il5ZLrTa49YPQ3zc4zeR5mDCH /uqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rlngRWZT; 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 e13si6711920eja.305.2020.11.09.05.37.10; Mon, 09 Nov 2020 05:37:33 -0800 (PST) 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=rlngRWZT; 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 S1731598AbgKINd7 (ORCPT + 99 others); Mon, 9 Nov 2020 08:33:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:58854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731026AbgKINGE (ORCPT ); Mon, 9 Nov 2020 08:06:04 -0500 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 098FF20663; Mon, 9 Nov 2020 13:06:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927163; bh=/DgGfDv9KXJmJJkAmOKQEis+T+hpXrkSxv4BY9hKE1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rlngRWZTYDknH9tCxJhiCrPHJH7EQnLViTqcm1vgMFg076Pf2utUjUbJYsq2/svi4 /oCUkThsBYymkRXS0TpqyfSon42YoFx14Ci++hQV16tBUCL9ocibSqiGUfi+k/4P/w 89Fcd2tQKpghcoT5k9Jlc7VIm4Idlz/tIphHf+Nc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Martyna Szapar , Andrew Bowers , Jeff Kirsher , Ben Hutchings Subject: [PATCH 4.14 15/48] i40e: Memory leak in i40e_config_iwarp_qvlist Date: Mon, 9 Nov 2020 13:55:24 +0100 Message-Id: <20201109125017.494576058@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125016.734107741@linuxfoundation.org> References: <20201109125016.734107741@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: Martyna Szapar commit 0b63644602cfcbac849f7ea49272a39e90fa95eb upstream. Added freeing the old allocation of vf->qvlist_info in function i40e_config_iwarp_qvlist before overwriting it with the new allocation. Signed-off-by: Martyna Szapar Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Ben Hutchings 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 @@ -418,6 +418,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; @@ -426,16 +427,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; @@ -446,8 +450,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; @@ -489,10 +495,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; } /**