From patchwork Wed Oct 11 17:27:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10000129 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 A152960216 for ; Wed, 11 Oct 2017 17:27:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 88F2828AEF for ; Wed, 11 Oct 2017 17:27:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D72828AF1; Wed, 11 Oct 2017 17:27:34 +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 5A8AB28AEF for ; Wed, 11 Oct 2017 17:27:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751988AbdJKR1b (ORCPT ); Wed, 11 Oct 2017 13:27:31 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:4887 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751532AbdJKR1a (ORCPT ); Wed, 11 Oct 2017 13:27:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1507742851; x=1539278851; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=eDbDbWRnUMbKxnUgJpJhby9D/F8uTQIGYeKY58vnZGQ=; b=kDtAr12wz0ZBO+PgICtD3fXZ/S3rSf5x2MYqoj48YHdFfecC2gJW1deA rhirf+3IaMwU3d4x58+YqjmreOhzMZe6PUnbTNbgcY5I2yY33DrFiOFIv n/yS4KYVkccDmBBq7gjFYQtLrzeqeesxMQ6p3/RCZNBO6/i54A/q5FRGv vGLxl+om3CYoATJlj7O5FzlCWH9qMAgBx0Y5JbdbgpKNtofToczPuDdR4 5/EtnccYEB5yI0U3Q6rkFmtbw7kNHN2ObQZy9UuB80I7NRckG65eU/6bE UgBD+TE5SKo6C9/E5juvI4CEwV5gCYqbvvs0+8RQ/oPLjtpDetvYQsRAq g==; X-IronPort-AV: E=Sophos;i="5.43,362,1503331200"; d="scan'208";a="57885420" Received: from sjappemgw11.hgst.com (HELO sjappemgw12.hgst.com) ([199.255.44.62]) by ob1.hgst.iphmx.com with ESMTP; 12 Oct 2017 01:27:31 +0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.172.152]) by sjappemgw12.hgst.com with ESMTP; 11 Oct 2017 10:27:29 -0700 From: Bart Van Assche To: Doug Ledford Cc: linux-rdma@vger.kernel.org, Bart Van Assche , stable@vger.kernel.org Subject: [PATCH v2 1/8] IB/srpt: Do not accept invalid initiator port names Date: Wed, 11 Oct 2017 10:27:22 -0700 Message-Id: <20171011172729.16984-2-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171011172729.16984-1-bart.vanassche@wdc.com> References: <20171011172729.16984-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 Make srpt_parse_i_port_id() return a negative value if hex2bin() fails. Fixes: commit a42d985bd5b2 ("ib_srpt: Initial SRP Target merge for v3.3-rc1") Signed-off-by: Bart Van Assche Cc: --- drivers/infiniband/ulp/srpt/ib_srpt.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 9e8e9220f816..95178b4e3565 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -2777,7 +2777,7 @@ static int srpt_parse_i_port_id(u8 i_port_id[16], const char *name) { const char *p; unsigned len, count, leading_zero_bytes; - int ret, rc; + int ret; p = name; if (strncasecmp(p, "0x", 2) == 0) @@ -2789,10 +2789,9 @@ static int srpt_parse_i_port_id(u8 i_port_id[16], const char *name) count = min(len / 2, 16U); leading_zero_bytes = 16 - count; memset(i_port_id, 0, leading_zero_bytes); - rc = hex2bin(i_port_id + leading_zero_bytes, p, count); - if (rc < 0) - pr_debug("hex2bin failed for srpt_parse_i_port_id: %d\n", rc); - ret = 0; + ret = hex2bin(i_port_id + leading_zero_bytes, p, count); + if (ret < 0) + pr_debug("hex2bin failed for srpt_parse_i_port_id: %d\n", ret); out: return ret; }