IB/srpt: Do not accept invalid initiator port names
commitc70ca38960
upstream. Make srpt_parse_i_port_id() return a negative value if hex2bin() fails. Fixes: commita42d985bd5
("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
54a8d930b9
commit
3e32b40435
@ -3425,7 +3425,7 @@ static int srpt_parse_i_port_id(u8 i_port_id[16], const char *name)
|
|||||||
{
|
{
|
||||||
const char *p;
|
const char *p;
|
||||||
unsigned len, count, leading_zero_bytes;
|
unsigned len, count, leading_zero_bytes;
|
||||||
int ret, rc;
|
int ret;
|
||||||
|
|
||||||
p = name;
|
p = name;
|
||||||
if (strncasecmp(p, "0x", 2) == 0)
|
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)
|
|||||||
count = min(len / 2, 16U);
|
count = min(len / 2, 16U);
|
||||||
leading_zero_bytes = 16 - count;
|
leading_zero_bytes = 16 - count;
|
||||||
memset(i_port_id, 0, leading_zero_bytes);
|
memset(i_port_id, 0, leading_zero_bytes);
|
||||||
rc = hex2bin(i_port_id + leading_zero_bytes, p, count);
|
ret = hex2bin(i_port_id + leading_zero_bytes, p, count);
|
||||||
if (rc < 0)
|
if (ret < 0)
|
||||||
pr_debug("hex2bin failed for srpt_parse_i_port_id: %d\n", rc);
|
pr_debug("hex2bin failed for srpt_parse_i_port_id: %d\n", ret);
|
||||||
ret = 0;
|
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user