Skip to content

Commit 3e32b40

Browse files
KAGA-KOKOgregkh
authored andcommitted
IB/srpt: Do not accept invalid initiator port names
commit c70ca38960399a63d5c048b7b700612ea321d17e upstream. Make srpt_parse_i_port_id() return a negative value if hex2bin() fails. Fixes: commit a42d985 ("ib_srpt: Initial SRP Target merge for v3.3-rc1") Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 54a8d93 commit 3e32b40

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

drivers/infiniband/ulp/srpt/ib_srpt.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3425,7 +3425,7 @@ static int srpt_parse_i_port_id(u8 i_port_id[16], const char *name)
34253425
{
34263426
const char *p;
34273427
unsigned len, count, leading_zero_bytes;
3428-
int ret, rc;
3428+
int ret;
34293429

34303430
p = name;
34313431
if (strncasecmp(p, "0x", 2) == 0)
@@ -3437,10 +3437,9 @@ static int srpt_parse_i_port_id(u8 i_port_id[16], const char *name)
34373437
count = min(len / 2, 16U);
34383438
leading_zero_bytes = 16 - count;
34393439
memset(i_port_id, 0, leading_zero_bytes);
3440-
rc = hex2bin(i_port_id + leading_zero_bytes, p, count);
3441-
if (rc < 0)
3442-
pr_debug("hex2bin failed for srpt_parse_i_port_id: %d\n", rc);
3443-
ret = 0;
3440+
ret = hex2bin(i_port_id + leading_zero_bytes, p, count);
3441+
if (ret < 0)
3442+
pr_debug("hex2bin failed for srpt_parse_i_port_id: %d\n", ret);
34443443
out:
34453444
return ret;
34463445
}

0 commit comments

Comments
 (0)