From patchwork Sun Oct 29 13:01:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yishai Hadas X-Patchwork-Id: 10031435 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 78A8F603FF for ; Sun, 29 Oct 2017 13:01:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65B2428811 for ; Sun, 29 Oct 2017 13:01:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A65E28812; Sun, 29 Oct 2017 13:01:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 073FC28814 for ; Sun, 29 Oct 2017 13:01:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751582AbdJ2NBp (ORCPT ); Sun, 29 Oct 2017 09:01:45 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:36636 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751590AbdJ2NBn (ORCPT ); Sun, 29 Oct 2017 09:01:43 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from yishaih@mellanox.com) with ESMTPS (AES256-SHA encrypted); 29 Oct 2017 15:01:39 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [10.7.2.17]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v9TD1ckN012616; Sun, 29 Oct 2017 15:01:38 +0200 Received: from vnc17.mtl.labs.mlnx (vnc17.mtl.labs.mlnx [127.0.0.1]) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8) with ESMTP id v9TD1cec001482; Sun, 29 Oct 2017 15:01:38 +0200 Received: (from yishaih@localhost) by vnc17.mtl.labs.mlnx (8.13.8/8.13.8/Submit) id v9TD1cDP001481; Sun, 29 Oct 2017 15:01:38 +0200 From: Yishai Hadas To: linux-rdma@vger.kernel.org Cc: yishaih@mellanox.com, lariel@mellanox.com, majd@mellanox.com Subject: [PATCH rdma-core 2/2] mlx5: Fix wrong bitmap table allocation size calculation Date: Sun, 29 Oct 2017 15:01:10 +0200 Message-Id: <1509282070-1391-3-git-send-email-yishaih@mellanox.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1509282070-1391-1-git-send-email-yishaih@mellanox.com> References: <1509282070-1391-1-git-send-email-yishaih@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ariel Levkovich This fixes wrong element size calculation during allocation of bitmap table. We divide the number of required bits in the bitmap into groups (elements) of sizeof(long) which can be 4 or more bytes (architecture depended) but allocating num_elements * 4 bytes of memory for the table. Signed-off-by: Ariel Levkovich Reviewed-by: Yishai Hadas --- providers/mlx5/buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/providers/mlx5/buf.c b/providers/mlx5/buf.c index 8196db6..0ba8188 100644 --- a/providers/mlx5/buf.c +++ b/providers/mlx5/buf.c @@ -51,7 +51,7 @@ static int mlx5_bitmap_init(struct mlx5_bitmap *bitmap, uint32_t num, bitmap->avail = num; bitmap->mask = mask; bitmap->avail = bitmap->max; - bitmap->table = calloc(BITS_TO_LONGS(bitmap->max), sizeof(uint32_t)); + bitmap->table = calloc(BITS_TO_LONGS(bitmap->max), sizeof(long)); if (!bitmap->table) return -ENOMEM;