Commit df50c088 authored by Kazunori Miyazawa's avatar Kazunori Miyazawa Committed by David S. Miller

[IPSEC]: Fix processing of error from crypto module.

ESP needs to check for error returns from calls
to crypto_cipher_setkey().
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 526160d9
...@@ -427,7 +427,8 @@ static int esp_init_state(struct xfrm_state *x, void *args) ...@@ -427,7 +427,8 @@ static int esp_init_state(struct xfrm_state *x, void *args)
goto error; goto error;
get_random_bytes(esp->conf.ivec, esp->conf.ivlen); get_random_bytes(esp->conf.ivec, esp->conf.ivlen);
} }
crypto_cipher_setkey(esp->conf.tfm, esp->conf.key, esp->conf.key_len); if (crypto_cipher_setkey(esp->conf.tfm, esp->conf.key, esp->conf.key_len))
goto error;
x->props.header_len = sizeof(struct ip_esp_hdr) + esp->conf.ivlen; x->props.header_len = sizeof(struct ip_esp_hdr) + esp->conf.ivlen;
if (x->props.mode) if (x->props.mode)
x->props.header_len += sizeof(struct iphdr); x->props.header_len += sizeof(struct iphdr);
......
...@@ -364,7 +364,8 @@ static int esp6_init_state(struct xfrm_state *x, void *args) ...@@ -364,7 +364,8 @@ static int esp6_init_state(struct xfrm_state *x, void *args)
goto error; goto error;
get_random_bytes(esp->conf.ivec, esp->conf.ivlen); get_random_bytes(esp->conf.ivec, esp->conf.ivlen);
} }
crypto_cipher_setkey(esp->conf.tfm, esp->conf.key, esp->conf.key_len); if (crypto_cipher_setkey(esp->conf.tfm, esp->conf.key, esp->conf.key_len))
goto error;
x->props.header_len = sizeof(struct ipv6_esp_hdr) + esp->conf.ivlen; x->props.header_len = sizeof(struct ipv6_esp_hdr) + esp->conf.ivlen;
if (x->props.mode) if (x->props.mode)
x->props.header_len += sizeof(struct ipv6hdr); x->props.header_len += sizeof(struct ipv6hdr);
...@@ -372,15 +373,9 @@ static int esp6_init_state(struct xfrm_state *x, void *args) ...@@ -372,15 +373,9 @@ static int esp6_init_state(struct xfrm_state *x, void *args)
return 0; return 0;
error: error:
if (esp) { x->data = esp;
if (esp->auth.tfm) esp6_destroy(x);
crypto_free_tfm(esp->auth.tfm); x->data = NULL;
if (esp->auth.work_icv)
kfree(esp->auth.work_icv);
if (esp->conf.tfm)
crypto_free_tfm(esp->conf.tfm);
kfree(esp);
}
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment