diff options
Diffstat (limited to 'drivers/target/iscsi/iscsi_target_auth.c')
-rw-r--r-- | drivers/target/iscsi/iscsi_target_auth.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/target/iscsi/iscsi_target_auth.c b/drivers/target/iscsi/iscsi_target_auth.c index 903b667f8e01..f9bc8ec6fb6b 100644 --- a/drivers/target/iscsi/iscsi_target_auth.c +++ b/drivers/target/iscsi/iscsi_target_auth.c | |||
@@ -47,18 +47,21 @@ static void chap_binaryhex_to_asciihex(char *dst, char *src, int src_len) | |||
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | static void chap_gen_challenge( | 50 | static int chap_gen_challenge( |
51 | struct iscsi_conn *conn, | 51 | struct iscsi_conn *conn, |
52 | int caller, | 52 | int caller, |
53 | char *c_str, | 53 | char *c_str, |
54 | unsigned int *c_len) | 54 | unsigned int *c_len) |
55 | { | 55 | { |
56 | int ret; | ||
56 | unsigned char challenge_asciihex[CHAP_CHALLENGE_LENGTH * 2 + 1]; | 57 | unsigned char challenge_asciihex[CHAP_CHALLENGE_LENGTH * 2 + 1]; |
57 | struct iscsi_chap *chap = conn->auth_protocol; | 58 | struct iscsi_chap *chap = conn->auth_protocol; |
58 | 59 | ||
59 | memset(challenge_asciihex, 0, CHAP_CHALLENGE_LENGTH * 2 + 1); | 60 | memset(challenge_asciihex, 0, CHAP_CHALLENGE_LENGTH * 2 + 1); |
60 | 61 | ||
61 | get_random_bytes(chap->challenge, CHAP_CHALLENGE_LENGTH); | 62 | ret = get_random_bytes_wait(chap->challenge, CHAP_CHALLENGE_LENGTH); |
63 | if (unlikely(ret)) | ||
64 | return ret; | ||
62 | chap_binaryhex_to_asciihex(challenge_asciihex, chap->challenge, | 65 | chap_binaryhex_to_asciihex(challenge_asciihex, chap->challenge, |
63 | CHAP_CHALLENGE_LENGTH); | 66 | CHAP_CHALLENGE_LENGTH); |
64 | /* | 67 | /* |
@@ -69,6 +72,7 @@ static void chap_gen_challenge( | |||
69 | 72 | ||
70 | pr_debug("[%s] Sending CHAP_C=0x%s\n\n", (caller) ? "server" : "client", | 73 | pr_debug("[%s] Sending CHAP_C=0x%s\n\n", (caller) ? "server" : "client", |
71 | challenge_asciihex); | 74 | challenge_asciihex); |
75 | return 0; | ||
72 | } | 76 | } |
73 | 77 | ||
74 | static int chap_check_algorithm(const char *a_str) | 78 | static int chap_check_algorithm(const char *a_str) |
@@ -143,6 +147,7 @@ static struct iscsi_chap *chap_server_open( | |||
143 | case CHAP_DIGEST_UNKNOWN: | 147 | case CHAP_DIGEST_UNKNOWN: |
144 | default: | 148 | default: |
145 | pr_err("Unsupported CHAP_A value\n"); | 149 | pr_err("Unsupported CHAP_A value\n"); |
150 | kfree(conn->auth_protocol); | ||
146 | return NULL; | 151 | return NULL; |
147 | } | 152 | } |
148 | 153 | ||
@@ -156,7 +161,10 @@ static struct iscsi_chap *chap_server_open( | |||
156 | /* | 161 | /* |
157 | * Generate Challenge. | 162 | * Generate Challenge. |
158 | */ | 163 | */ |
159 | chap_gen_challenge(conn, 1, aic_str, aic_len); | 164 | if (chap_gen_challenge(conn, 1, aic_str, aic_len) < 0) { |
165 | kfree(conn->auth_protocol); | ||
166 | return NULL; | ||
167 | } | ||
160 | 168 | ||
161 | return chap; | 169 | return chap; |
162 | } | 170 | } |