From patchwork Tue Jan 3 13:45:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Gurtovoy X-Patchwork-Id: 9494863 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 26339606B4 for ; Tue, 3 Jan 2017 13:46:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1079026E51 for ; Tue, 3 Jan 2017 13:46:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01C1E26E81; Tue, 3 Jan 2017 13:46:31 +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 E3AD326C9B for ; Tue, 3 Jan 2017 13:46:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757856AbdACNqZ (ORCPT ); Tue, 3 Jan 2017 08:46:25 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:40971 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759103AbdACNpl (ORCPT ); Tue, 3 Jan 2017 08:45:41 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from maxg@mellanox.com) with ESMTPS (AES256-SHA encrypted); 3 Jan 2017 15:45:34 +0200 Received: from r-vnc08.mtr.labs.mlnx (r-vnc08.mtr.labs.mlnx [10.208.0.121]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v03DjYnj020286; Tue, 3 Jan 2017 15:45:34 +0200 From: Max Gurtovoy To: bvanassche@acm.org, linux-rdma@vger.kernel.org Cc: israelr@mellanox.com, Max Gurtovoy Subject: [PATCHv1 1/1] IB/srp: fix invalid indirect_sg_entries parameter value Date: Tue, 3 Jan 2017 15:45:33 +0200 Message-Id: <1483451133-6308-2-git-send-email-maxg@mellanox.com> X-Mailer: git-send-email 1.7.8.2 In-Reply-To: <1483451133-6308-1-git-send-email-maxg@mellanox.com> References: <1483451133-6308-1-git-send-email-maxg@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: Israel Rukshin After setting indirect_sg_entries module_param to huge value (e.g 500,000), srp_alloc_req_data() fails to allocate indirect descriptors for the request ring (kmalloc fails). This commit enforces the maximum value of indirect_sg_entries to be SG_MAX_SEGMENTS as signified in module param description. Signed-off-by: Israel Rukshin Signed-off-by: Max Gurtovoy --- drivers/infiniband/ulp/srp/ib_srp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 0f67cf9..ccdd2c2 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -3676,6 +3676,7 @@ static struct srp_function_template ib_srp_transport_functions = { static int __init srp_init_module(void) { int ret; + unsigned int max_indirect_sg_entries = SG_MAX_SEGMENTS; if (srp_sg_tablesize) { pr_warn("srp_sg_tablesize is deprecated, please use cmd_sg_entries\n"); @@ -3699,6 +3700,12 @@ static int __init srp_init_module(void) indirect_sg_entries = cmd_sg_entries; } + if (indirect_sg_entries > max_indirect_sg_entries) { + pr_warn("Clamping indirect_sg_entries to %u\n", + max_indirect_sg_entries); + indirect_sg_entries = max_indirect_sg_entries; + } + srp_remove_wq = create_workqueue("srp_remove"); if (!srp_remove_wq) { ret = -ENOMEM;