]> git.hungrycats.org Git - linux/commitdiff
IB/srpt: Do not accept invalid initiator port names
authorBart Van Assche <bart.vanassche@wdc.com>
Wed, 11 Oct 2017 17:27:22 +0000 (10:27 -0700)
committerSasha Levin <alexander.levin@verizon.com>
Fri, 8 Dec 2017 23:01:05 +0000 (18:01 -0500)
[ Upstream commit c70ca38960399a63d5c048b7b700612ea321d17e ]

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 <bart.vanassche@wdc.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
drivers/infiniband/ulp/srpt/ib_srpt.c

index 27e5b0090e40c646300ba5a4bfdcc0fcab7a8ea7..416cd07ab87a48a1b7a3abcbee35bee9cb1fa6c2 100644 (file)
@@ -3516,7 +3516,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)
@@ -3528,10 +3528,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;
 }