Skip to content

Commit

Permalink
IB/srpt: Do not accept invalid initiator port names
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: <[email protected]>
Signed-off-by: Doug Ledford <[email protected]>
  • Loading branch information
KAGA-KOKO authored and dledford committed Oct 18, 2017
1 parent 69abc73 commit c70ca38
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions drivers/infiniband/ulp/srpt/ib_srpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down

0 comments on commit c70ca38

Please sign in to comment.