Commit 345d4103 authored by Krishna Kumar's avatar Krishna Kumar Committed by David S. Miller

[IPV4/IPV6]: Add missing kmalloc failure checks.

parent e88141bd
......@@ -518,6 +518,8 @@ int esp_init_state(struct xfrm_state *x, void *args)
esp->conf.padlen = 0;
if (esp->conf.ivlen) {
esp->conf.ivec = kmalloc(esp->conf.ivlen, GFP_KERNEL);
if (unlikely(esp->conf.ivec == NULL))
goto error;
get_random_bytes(esp->conf.ivec, esp->conf.ivlen);
}
crypto_cipher_setkey(esp->conf.tfm, esp->conf.key, esp->conf.key_len);
......
......@@ -761,8 +761,11 @@ int ip_append_data(struct sock *sk,
*/
opt = ipc->opt;
if (opt) {
if (inet->cork.opt == NULL)
if (inet->cork.opt == NULL) {
inet->cork.opt = kmalloc(sizeof(struct ip_options) + 40, sk->sk_allocation);
if (unlikely(inet->cork.opt == NULL))
return -ENOBUFS;
}
memcpy(inet->cork.opt, opt, sizeof(struct ip_options)+opt->optlen);
inet->cork.flags |= IPCORK_OPT;
inet->cork.addr = ipc->addr;
......
......@@ -422,6 +422,8 @@ int esp6_init_state(struct xfrm_state *x, void *args)
esp->conf.padlen = 0;
if (esp->conf.ivlen) {
esp->conf.ivec = kmalloc(esp->conf.ivlen, GFP_KERNEL);
if (unlikely(esp->conf.ivec == NULL))
goto error;
get_random_bytes(esp->conf.ivec, esp->conf.ivlen);
}
crypto_cipher_setkey(esp->conf.tfm, esp->conf.key, esp->conf.key_len);
......
......@@ -816,9 +816,12 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, int offse
* setup for corking
*/
if (opt) {
if (np->cork.opt == NULL)
if (np->cork.opt == NULL) {
np->cork.opt = kmalloc(opt->tot_len,
sk->sk_allocation);
if (unlikely(np->cork.opt == NULL))
return -ENOBUFS;
}
memcpy(np->cork.opt, opt, opt->tot_len);
inet->cork.flags |= IPCORK_OPT;
/* need source address above miyazawa*/
......
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