From patchwork Mon Jan 8 23:14:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10150747 X-Patchwork-Delegate: dledford@redhat.com 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 CFAC7601BE for ; Mon, 8 Jan 2018 23:14:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C492E289F7 for ; Mon, 8 Jan 2018 23:14:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7D8028A01; Mon, 8 Jan 2018 23:14:46 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 60D08289F7 for ; Mon, 8 Jan 2018 23:14:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758163AbeAHXOn (ORCPT ); Mon, 8 Jan 2018 18:14:43 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:39372 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758161AbeAHXOi (ORCPT ); Mon, 8 Jan 2018 18:14:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1515453278; x=1546989278; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=skXSzG4Gr4vmbWD9fHCzDQtLwMpJxd9qDihZqLjChQU=; b=N6NruNP6bArwjrQRCudX4PWmVdeLDTD0pP3CRxoH+ppp+MHLSXqKmq56 KGpEr/jJQEBHdI78jgQn2fROxfM3L34RjnfzNp6uzFpwi1A8mcK8n1+QH U0d+9mi4U9kpz3CSTtLOffX2IsNmIcwnlXapKgHBEbRAaZpS52VEX3zOX 5u4jO4XQIkhK+ABxBz5U46lPm9P8x77JHhpNv8OB5w3OUyGDhn7ZgRuOQ HrAZzTFuLvU9Hd/2YBz9yypf+QPEO75leMXEyuz8VCWFgkmm1d1dlpqYo zKJyTbx5z2LtxYgpqXv/FPo62EfOJ9RntiXaGiUlVZ7Bpk/tIPZHMWfHY w==; X-IronPort-AV: E=Sophos;i="5.46,333,1511798400"; d="scan'208";a="171025580" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 09 Jan 2018 07:14:37 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 08 Jan 2018 15:10:34 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.46.240]) by uls-op-cesaip02.wdc.com with ESMTP; 08 Jan 2018 15:14:36 -0800 From: Bart Van Assche To: Jason Gunthorpe Cc: Doug Ledford , Greg Kroah-Hartman , linux-rdma@vger.kernel.org, Bart Van Assche Subject: [PATCH v3 2/5] IB/srp: Use kstrtoull() instead of simple_strtoull() Date: Mon, 8 Jan 2018 15:14:33 -0800 Message-Id: <20180108231436.19750-3-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180108231436.19750-1-bart.vanassche@wdc.com> References: <20180108231436.19750-1-bart.vanassche@wdc.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 Use kstrtoull() since simple_strtoull() is deprecated. This patch improves error checking but otherwise does not change any functionality. Signed-off-by: Bart Van Assche --- drivers/infiniband/ulp/srp/ib_srp.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 62d88212c1b0..39b3e43efbbe 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -3111,6 +3111,7 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target) char *options, *sep_opt; char *p; substring_t args[MAX_OPT_ARGS]; + unsigned long long ull; int opt_mask = 0; int token; int ret = -EINVAL; @@ -3135,7 +3136,13 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target) ret = -ENOMEM; goto out; } - target->id_ext = cpu_to_be64(simple_strtoull(p, NULL, 16)); + ret = kstrtoull(p, 16, &ull); + if (ret) { + pr_warn("invalid id_ext parameter '%s'\n", p); + kfree(p); + goto out; + } + target->id_ext = cpu_to_be64(ull); kfree(p); break; @@ -3145,7 +3152,13 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target) ret = -ENOMEM; goto out; } - target->ioc_guid = cpu_to_be64(simple_strtoull(p, NULL, 16)); + ret = kstrtoull(p, 16, &ull); + if (ret) { + pr_warn("invalid ioc_guid parameter '%s'\n", p); + kfree(p); + goto out; + } + target->ioc_guid = cpu_to_be64(ull); kfree(p); break; @@ -3181,7 +3194,13 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target) ret = -ENOMEM; goto out; } - target->service_id = cpu_to_be64(simple_strtoull(p, NULL, 16)); + ret = kstrtoull(p, 16, &ull); + if (ret) { + pr_warn("bad service_id parameter '%s'\n", p); + kfree(p); + goto out; + } + target->service_id = cpu_to_be64(ull); kfree(p); break; @@ -3235,7 +3254,13 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target) ret = -ENOMEM; goto out; } - target->initiator_ext = cpu_to_be64(simple_strtoull(p, NULL, 16)); + ret = kstrtoull(p, 16, &ull); + if (ret) { + pr_warn("bad initiator_ext value '%s'\n", p); + kfree(p); + goto out; + } + target->initiator_ext = cpu_to_be64(ull); kfree(p); break;