From patchwork Wed Oct 23 06:53:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 3086151 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B14A2BF924 for ; Wed, 23 Oct 2013 06:53:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0ABC202C3 for ; Wed, 23 Oct 2013 06:53:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE9F1202C1 for ; Wed, 23 Oct 2013 06:53:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751316Ab3JWGx3 (ORCPT ); Wed, 23 Oct 2013 02:53:29 -0400 Received: from mail-ee0-f42.google.com ([74.125.83.42]:64288 "EHLO mail-ee0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751051Ab3JWGx3 (ORCPT ); Wed, 23 Oct 2013 02:53:29 -0400 Received: by mail-ee0-f42.google.com with SMTP id b45so192429eek.29 for ; Tue, 22 Oct 2013 23:53:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2PGSyk9Af7ROK7ZgNnHamuWqkEZUUcSx5c+juGwEhD8=; b=cIBHtyy9yxN5lZkhQ149SWhaio8DSjpKejjQ7dZiMbwZ4o7KYQreccgO06uu60TklK FDfYjGd/9CY+Atn4lleBJ+T9MJSqy3rQhzIqiXzhNtjhmOTBdPIov0dMprBxYTGtYLLj NtK356zEHvKMrGrMSe10T7Hyp4ntRr+E4C0W7uVrR/WX/FZEQFzoaaBvVMd93xhchqKH 6my+HMPzrlQtHFyNsGMH0Z5rqCKemghDE3BxaWl3GwGWvQPPwkRnMHcnTMeofX+S8DjE 6YjyVfkphRuPR2H5v9vrYlqJW9iUVAk7He2DA71GtKPWFmkeCu1Et7IP6qhp/ZddX+Pw bwTQ== X-Gm-Message-State: ALoCoQmXqKMYLlCo7gzYKUre+T1/4o/qpXzM1HJDwycBI+0LEYmCIh53hD4y2HQKr9S5yogviGa4 X-Received: by 10.15.61.66 with SMTP id h42mr117243eex.62.1382511208172; Tue, 22 Oct 2013 23:53:28 -0700 (PDT) Received: from localhost (out.voltaire.com. [193.47.165.251]) by mx.google.com with ESMTPSA id k7sm66186847eeg.13.2013.10.22.23.53.27 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 22 Oct 2013 23:53:27 -0700 (PDT) From: Eli Cohen To: roland@kernel.org Cc: linux-rdma@vger.kernel.org, amirv@mellanox.com, ogerlitz@mellanox.com, yevgenyp@mellanox.com, Eli Cohen Subject: [PATCH for-next 1/9] IB/mlx5: Fix check of number of entries in create CQ Date: Wed, 23 Oct 2013 09:53:13 +0300 Message-Id: <1382511201-7061-2-git-send-email-eli@mellanox.com> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1382511201-7061-1-git-send-email-eli@mellanox.com> References: <1382511201-7061-1-git-send-email-eli@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Verify that the value is non negative before rounding up to power of 2. Signed-off-by: Eli Cohen --- drivers/infiniband/hw/mlx5/cq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c index 344ab03..e7c64c5 100644 --- a/drivers/infiniband/hw/mlx5/cq.c +++ b/drivers/infiniband/hw/mlx5/cq.c @@ -653,8 +653,11 @@ struct ib_cq *mlx5_ib_create_cq(struct ib_device *ibdev, int entries, int eqn; int err; + if (entries < 0) + return ERR_PTR(-EINVAL); + entries = roundup_pow_of_two(entries + 1); - if (entries < 1 || entries > dev->mdev.caps.max_cqes) + if (entries > dev->mdev.caps.max_cqes) return ERR_PTR(-EINVAL); cq = kzalloc(sizeof(*cq), GFP_KERNEL);