Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2536746yba; Mon, 6 May 2019 07:40:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYPev2X/p2EXWlMUtV0q34YYd572odECmrRtm3a4wbfEwytn4Ffo3XbuhQ/TLEw3H3AaWN X-Received: by 2002:a65:64d3:: with SMTP id t19mr32804408pgv.57.1557153604876; Mon, 06 May 2019 07:40:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557153604; cv=none; d=google.com; s=arc-20160816; b=tT4apAEvU1fS3ZtDctuBlMnknXTs8J0kDQm5J1BSawu9WGCvw2HFY1S8wcatz2xH0V YDIzvZTtkaDt4sL4Xi6e9A+oWM2zR6rYpDPR6/Nt90aJVCJtsgw8FCwnLf1wVkDT5vRh MvQZJoq8AlkYTOCJc4mMg311Wsmeyc4q9O2PfLKF0czzA6YGtIY9TWgVAesq9QakbKuX CNKiebCu//iu+jx1hrEZBXk3wFUMjkA7HzqTRcYy/7Q4RftdTMgwquzXgheDGWk7uj4T 1vMdj7xkwIzuQKRrvdXYB7nTe8PixN6lsVXvIispctX3kGndLLug1Novrr64xvZJFAIZ EhpQ== 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=EdL+x3FuoFoWS8SeAKclbCBdD9P0EiBW0iJZcdinH14=; b=DfJFZ32KUETWtqU+nC/W0lXVDTxFuDnKe7H8KNPsDgU4MS8DeIlkiCA7i9SYTjwS2b 84HouAJC4gax8LCWHkJ+5QL42catzAjBRc9LI+Qmf/n6W+RsO0IuJaq2zKFjFXvzZjzN UQyUDKZC9JW/GfOcwCU2drl2okuodhWNjypJFDJaqRS7poeZx/qkelFWxWQN8LGDH2ga HTJ6jvoFxGLNqZxuAOnyffD9kIGlJxp3C8QRkoAe4mDAIRGdHb6PhT1HBPim8e+M80IZ 0oovwEoVpxkUg3DPhEH2DVnt9kuhN/3tJ+NARycn9nw/JufcXe+K1C+81/UDqzbt746u fIRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AXpDTPIB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si17002274pgf.112.2019.05.06.07.39.48; Mon, 06 May 2019 07:40:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AXpDTPIB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726261AbfEFOgn (ORCPT + 99 others); Mon, 6 May 2019 10:36:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:57106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726755AbfEFOgl (ORCPT ); Mon, 6 May 2019 10:36:41 -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 25A86204EC; Mon, 6 May 2019 14:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153400; bh=EQp7oXnTmCsCwvZ8Cp0LLZDWRQp/lNx09s7/4MGjgmg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AXpDTPIBa9DPYzuDhVc+GRh19XML8OFnL2Qp/7suWx21uUqVueWAnokvf2q9lzc+H +D4AqOFUxweK6JmIKbfBCCFh6KhN0rozNos+fFbWkWlo26va0q4fyYXUDozhipZzAT sPOw/VZZm1PDlSGi3LUeNq4LDZyu0xq449FZvBP0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Varun Prakash , "David S. Miller" , "Sasha Levin (Microsoft)" Subject: [PATCH 5.0 073/122] libcxgb: fix incorrect ppmax calculation Date: Mon, 6 May 2019 16:32:11 +0200 Message-Id: <20190506143101.466252453@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143054.670334917@linuxfoundation.org> References: <20190506143054.670334917@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 [ Upstream commit cc5a726c79158bd307150e8d4176ec79b52001ea ] BITS_TO_LONGS() uses DIV_ROUND_UP() because of this ppmax value can be greater than available per cpu page pods. This patch removes BITS_TO_LONGS() to fix this issue. Signed-off-by: Varun Prakash Signed-off-by: David S. Miller Signed-off-by: Sasha Levin (Microsoft) --- drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c index 74849be5f004..e2919005ead3 100644 --- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c +++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c @@ -354,7 +354,10 @@ static struct cxgbi_ppm_pool *ppm_alloc_cpu_pool(unsigned int *total, ppmax = max; /* pool size must be multiple of unsigned long */ - bmap = BITS_TO_LONGS(ppmax); + bmap = ppmax / BITS_PER_TYPE(unsigned long); + if (!bmap) + return NULL; + ppmax = (bmap * sizeof(unsigned long)) << 3; alloc_sz = sizeof(*pools) + sizeof(unsigned long) * bmap; @@ -402,6 +405,10 @@ int cxgbi_ppm_init(void **ppm_pp, struct net_device *ndev, if (reserve_factor) { ppmax_pool = ppmax / reserve_factor; pool = ppm_alloc_cpu_pool(&ppmax_pool, &pool_index_max); + if (!pool) { + ppmax_pool = 0; + reserve_factor = 0; + } pr_debug("%s: ppmax %u, cpu total %u, per cpu %u.\n", ndev->name, ppmax, ppmax_pool, pool_index_max); -- 2.20.1