Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4140464pxk; Tue, 8 Sep 2020 11:40:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHgVQacMrGRoSRcJ8AlbK+8RU4v3J9/0D6vg6hk0jHC6ebYXkIJ+s4DeUtv8DrOeypSa2H X-Received: by 2002:a50:fa81:: with SMTP id w1mr358148edr.122.1599590449391; Tue, 08 Sep 2020 11:40:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599590449; cv=none; d=google.com; s=arc-20160816; b=wVI7DtA3vdJcDrkBi+Xr1DwPWzcUvmCo0VTBiRHfH/Exz5wMw3UIPP88Ia6FpwsCE+ +qfCwEFix7UuF4siwlkxP/Nyiu3MVuCQJARKR9pPfNcW6AE+Uy7dWbv4Fl5kCum6nEuf v0HM7sIkJfcU4Fk3UkuggukK+YTkXAsti47UlLiXRXG7rTPdRNZAsQeUy8g4SZuIxc62 UmxXdoLXbhR2AwpjlEY6iM3qzaHCeN9hiltyituKGXcey8gCglS7MILt0dGvNn2FBk9o NBZCO/uIvTNdV+ICfQJeMOPD7bQiAmm09+ocko1Gtb5bSImntj/a0jO/qwF4b9z+I4cd DiCQ== 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=/89vC3GlIW71aWSBZVULEZQLJ235n2fUnR/E4BsIA5E=; b=id9RfRC862BGUwl89s+gVPj9Ywf2MqPcK72r+iNQYaFvtV0UmqYnYNFkI7EhwOxU2F w2SK8/Kdn5fRj5y7CQdo+dGZCCbEqS2FeKE4JhT3BGS77UM0qX8/q9hVqzgxVhmEf7nN jwouhaWBFIQFAl/t2ddjg1PclGlNygdFFbdu9rXO5v3fdgqdr7HxPeVqRlrwnQCyVLw6 Ku9PaZML7ZNgFS/f4yjv/Up5AkzGE+Wg5Zv8ZOpfLUKVRC8fEFBbS9BHGcs3g3OnMWj7 J1HggLF8zLXRq3BdDFvAccO8yVdo1RiA6/izsVSLUmJMaS/TPEdkm9pT8U9grjGR4AUb WtpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K8rExpF9; 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 f14si11781183ejq.98.2020.09.08.11.40.26; Tue, 08 Sep 2020 11:40:49 -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=K8rExpF9; 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 S1731841AbgIHSiH (ORCPT + 99 others); Tue, 8 Sep 2020 14:38:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:53538 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731336AbgIHQJA (ORCPT ); Tue, 8 Sep 2020 12:09:00 -0400 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 D2A3A24061; Tue, 8 Sep 2020 15:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599580134; bh=QDY3/kFueJcsMt1b0ZKfYh3Q1QDZa4GUx5uBD6WnL40=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K8rExpF98YUZwbRKv/sLhJjp4nPeFX9bjTaxerhrAyK/3tC1Y0FgQTGB+A97NInzw id92OdIqDnUQ3dC6mZnJA/kqp6b0QqihQg7buL1BM/ny0k5pm8q4oe3llbX+GB/E8I /i92ih+soAO2t87u9vqChEKY8ybZu9946KSl1rJg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shung-Hsi Yu , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 41/88] net: ethernet: mlx4: Fix memory allocation in mlx4_buddy_init() Date: Tue, 8 Sep 2020 17:25:42 +0200 Message-Id: <20200908152223.178555420@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908152221.082184905@linuxfoundation.org> References: <20200908152221.082184905@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: Shung-Hsi Yu [ Upstream commit cbedcb044e9cc4e14bbe6658111224bb923094f4 ] On machines with much memory (> 2 TByte) and log_mtts_per_seg == 0, a max_order of 31 will be passed to mlx_buddy_init(), which results in s = BITS_TO_LONGS(1 << 31) becoming a negative value, leading to kvmalloc_array() failure when it is converted to size_t. mlx4_core 0000:b1:00.0: Failed to initialize memory region table, aborting mlx4_core: probe of 0000:b1:00.0 failed with error -12 Fix this issue by changing the left shifting operand from a signed literal to an unsigned one. Fixes: 225c7b1feef1 ("IB/mlx4: Add a driver Mellanox ConnectX InfiniBand adapters") Signed-off-by: Shung-Hsi Yu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/mellanox/mlx4/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c index 1a11bc0e16123..cfa0bba3940fb 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mr.c +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c @@ -114,7 +114,7 @@ static int mlx4_buddy_init(struct mlx4_buddy *buddy, int max_order) goto err_out; for (i = 0; i <= buddy->max_order; ++i) { - s = BITS_TO_LONGS(1 << (buddy->max_order - i)); + s = BITS_TO_LONGS(1UL << (buddy->max_order - i)); buddy->bits[i] = kvmalloc_array(s, sizeof(long), GFP_KERNEL | __GFP_ZERO); if (!buddy->bits[i]) goto err_out_free; -- 2.25.1