]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.18.85/ib-srpt-do-not-accept-invalid-initiator-port-names.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.18.85 / ib-srpt-do-not-accept-invalid-initiator-port-names.patch
1 From c70ca38960399a63d5c048b7b700612ea321d17e Mon Sep 17 00:00:00 2001
2 From: Bart Van Assche <bart.vanassche@wdc.com>
3 Date: Wed, 11 Oct 2017 10:27:22 -0700
4 Subject: IB/srpt: Do not accept invalid initiator port names
5
6 From: Bart Van Assche <bart.vanassche@wdc.com>
7
8 commit c70ca38960399a63d5c048b7b700612ea321d17e upstream.
9
10 Make srpt_parse_i_port_id() return a negative value if hex2bin()
11 fails.
12
13 Fixes: commit a42d985bd5b2 ("ib_srpt: Initial SRP Target merge for v3.3-rc1")
14 Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
15 Signed-off-by: Doug Ledford <dledford@redhat.com>
16 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17
18 ---
19 drivers/infiniband/ulp/srpt/ib_srpt.c | 9 ++++-----
20 1 file changed, 4 insertions(+), 5 deletions(-)
21
22 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c
23 +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
24 @@ -3522,7 +3522,7 @@ static int srpt_parse_i_port_id(u8 i_por
25 {
26 const char *p;
27 unsigned len, count, leading_zero_bytes;
28 - int ret, rc;
29 + int ret;
30
31 p = name;
32 if (strncasecmp(p, "0x", 2) == 0)
33 @@ -3534,10 +3534,9 @@ static int srpt_parse_i_port_id(u8 i_por
34 count = min(len / 2, 16U);
35 leading_zero_bytes = 16 - count;
36 memset(i_port_id, 0, leading_zero_bytes);
37 - rc = hex2bin(i_port_id + leading_zero_bytes, p, count);
38 - if (rc < 0)
39 - pr_debug("hex2bin failed for srpt_parse_i_port_id: %d\n", rc);
40 - ret = 0;
41 + ret = hex2bin(i_port_id + leading_zero_bytes, p, count);
42 + if (ret < 0)
43 + pr_debug("hex2bin failed for srpt_parse_i_port_id: %d\n", ret);
44 out:
45 return ret;
46 }