Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3959523pxb; Mon, 4 Oct 2021 13:43:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNIT2g166dFdAPFWhQiocIP1e/r03onkzoiizKu4g7Nxz/RiYlqq0qiJBM3YcNNiJL/b6b X-Received: by 2002:a17:907:3352:: with SMTP id yr18mr2662286ejb.32.1633380207770; Mon, 04 Oct 2021 13:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633380207; cv=none; d=google.com; s=arc-20160816; b=SmiXQDmHN3HLL36maF+LIkAglZQKdQtEEWZIjs7wst69fuuz+4UDAMMoF781RiK1ZC u0eO9r2m7TmcLI7nLHpY85isEQq+huThcofOt7CfwensuHuXgxgvlvarGUW2I93CQXS7 yt2l78RxB//q1vdKHWm8GDfmjGh7cZ7hfQiri90PWIPvq8IxSMSNln9QujrK+vCLUTC7 khatYraHL3Wd5VthF7I4FqXm7GfZ+otjySD7jwnR5Afvm9hrKAp2eYmHrjyZxMC4lcUX X+U2SNPBGsk9Pf15sfmLzLD0Kx0wCmK6POtd6LVrgYbakU2G+JTjVB4MDvcu2h7SE45J eqXA== 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=RNnmviRcgGkTqtq+oOKeX4rPc3IE9syAWVTzgc9ugn4=; b=p+aoilaBxYZ2do3t48ltJAi7JDLrb0tSmZijG/nlbnnlYpV3euirH2qXelHym3DFqM bVXnK7oqB5v4AKeVomldTUIIaLVqunK2wFnKlBVQpBEDJf4hXqSmxVBIAnf1/ln6+fC0 8LJQGhed/PgIYuKDk+GbXXTaCFNfxbPb7SzLdgJyfFM/4OFl6j8BEx6rN8qfsYcfChcA Lskk5pUVdj+5LPBoktWCrxt4kTB6RA56lAdXx+6g058cMsqM9KN/rU95BJuLbdrEoFqi fWp3XeuO4t4TLh5HyxszYXgsFK4+CVOAbuICNPs4i3TEmjEM0FkJ5cHHTc/n9S9qK/8v Au0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PQT7xb4c; 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 hk24si19439042ejb.480.2021.10.04.13.43.00; Mon, 04 Oct 2021 13:43:27 -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=PQT7xb4c; 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 S238071AbhJDNiI (ORCPT + 99 others); Mon, 4 Oct 2021 09:38:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:51040 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237358AbhJDNgH (ORCPT ); Mon, 4 Oct 2021 09:36:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C008560FC1; Mon, 4 Oct 2021 13:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353386; bh=MOVB2EVEGBw+2mcUPRQksY8mvQOqtJOcvIvCwzLcoD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PQT7xb4cNqGWXC2KsfzBCor6cfEox4EmtGicxJe50a/XuSB2tviMJHjUKweSNaDlk I+Ucq11nifOnhv4D2/EkSKPjCUvt883sTPkplg1JjUTCpjEZdn0UhNp+PyrvvlYTTL BVqH8pzzOVFkf7zWtotDEKcF8U2yXYJCMnabDDWE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felicitas Hetzelt , Jacob Keller , Tony Nguyen , Sasha Levin Subject: [PATCH 5.14 109/172] e100: fix length calculation in e100_get_regs_len Date: Mon, 4 Oct 2021 14:52:39 +0200 Message-Id: <20211004125048.501036388@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@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: Jacob Keller [ Upstream commit 4329c8dc110b25d5f04ed20c6821bb60deff279f ] commit abf9b902059f ("e100: cleanup unneeded math") tried to simplify e100_get_regs_len and remove a double 'divide and then multiply' calculation that the e100_reg_regs_len function did. This change broke the size calculation entirely as it failed to account for the fact that the numbered registers are actually 4 bytes wide and not 1 byte. This resulted in a significant under allocation of the register buffer used by e100_get_regs. Fix this by properly multiplying the register count by u32 first before adding the size of the dump buffer. Fixes: abf9b902059f ("e100: cleanup unneeded math") Reported-by: Felicitas Hetzelt Signed-off-by: Jacob Keller Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/e100.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c index 1b0958bd24f6..71b9f0563b32 100644 --- a/drivers/net/ethernet/intel/e100.c +++ b/drivers/net/ethernet/intel/e100.c @@ -2441,7 +2441,11 @@ static void e100_get_drvinfo(struct net_device *netdev, static int e100_get_regs_len(struct net_device *netdev) { struct nic *nic = netdev_priv(netdev); - return 1 + E100_PHY_REGS + sizeof(nic->mem->dump_buf); + + /* We know the number of registers, and the size of the dump buffer. + * Calculate the total size in bytes. + */ + return (1 + E100_PHY_REGS) * sizeof(u32) + sizeof(nic->mem->dump_buf); } static void e100_get_regs(struct net_device *netdev, -- 2.33.0