Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3732428pxb; Mon, 4 Oct 2021 08:27:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwj1DPVUM01LGSyJe2nUIiTwPzN0ufC7RLckl8j+AY7gSxWnBIO8JuJAdcWxmDfQrMz8Cxh X-Received: by 2002:a17:90a:430e:: with SMTP id q14mr10979980pjg.55.1633361233099; Mon, 04 Oct 2021 08:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633361233; cv=none; d=google.com; s=arc-20160816; b=rIRfYlY0NMLA/jrdIhbvlHBaopTZTsBpBF6Fda31mZmlWioZT8JZEHcewvwsAJq03u 54yb9KuOGrGXf2W3IAAm9Z3DR4nL1AfTXsIXkhyExlafqiVEyf6jxAHfY1qg77Bswu25 DQlJnkwNfjDWzPYrge15BYvpnPGQsBwkevO0kxZqDpMyJYoVZKC8wK6VkpccS/u2fCv/ fYX3KtL3OcZdkLa0HNiGEJzao0zHPGVJVdkrewc01AnmjN7miCzagdKOUoiuvokG1JB9 QBcDyhyDMWEsRqDM7yQ5oBMmdgulL1D9frP5nFUYRrihr398I3lRHTPrSQ2V8J5xtTjU MzXw== 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=ylpdwDKPSDXl3fFlrGvJv9obRQ7JsjjTBuxLznrgyOg=; b=mk6oQoH1VAilv8lsHYODe1Bqrm52WcVs4xVVXDGaPAfLXbCYSITcEsL/48odrtEQUE 9SUAHxPiMvVS3LXC3x3fQMhcVsB5sk3uqvzSmYBOM4zJhsThIU1Zq1ijUI4URt/Dcxop HlWrJmOFfR9eeV0bDhTuLerNJ5nIqGOkX1whSuW+BYiryTsLarMRzcCvcMSiKRnJl3xo JtbpbTN8KWsgjxaAjWCwqTfwBCw95y5DwzR0cHrOIjKlqmFg5BRmP2qnIMNwQpfHxFiJ BycdFVEcw3T1BP4X1TCp+KejXfqkWYvHOq6OkAVowG83g/Xos5XfFIvt2jjnO2y2OgJL JG5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="gkkFE/7u"; 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 s191si17189675pgs.25.2021.10.04.08.26.59; Mon, 04 Oct 2021 08:27:13 -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="gkkFE/7u"; 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 S233648AbhJDNPQ (ORCPT + 99 others); Mon, 4 Oct 2021 09:15:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:46566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235846AbhJDNLO (ORCPT ); Mon, 4 Oct 2021 09:11:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4CBF861B00; Mon, 4 Oct 2021 13:04:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633352654; bh=KQ0MAXLog9S9CkOEoqNgYF4Dr7kSCdawMAXYE91Ib50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gkkFE/7uIfZlJfnoHPW1MXcxzea9hdWvbhkHFR/y/6Kb1Zi/axrrbaB078TffV6bx 7pmewFJl1ZDE++TmorXhf+x6l+/w5z0vmq3kcikH7GvYnqosgemhejmAD0myb0cgCD GIsSmSOEoC788MxAAwRUXPhi/rQ91n1l/Pz8d8pM= 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 4.19 70/95] e100: fix length calculation in e100_get_regs_len Date: Mon, 4 Oct 2021 14:52:40 +0200 Message-Id: <20211004125035.865428294@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125033.572932188@linuxfoundation.org> References: <20211004125033.572932188@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 bf64fab38385..4d27eaf05641 100644 --- a/drivers/net/ethernet/intel/e100.c +++ b/drivers/net/ethernet/intel/e100.c @@ -2437,7 +2437,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