Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
calipso: fix resource leak on calipso_genopt failure
Browse files Browse the repository at this point in the history
Currently, if calipso_genopt fails then the error exit path
does not free the ipv6_opt_hdr new causing a memory leak. Fix
this by kfree'ing new on the error exit path.

Signed-off-by: Colin Ian King <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Colin Ian King authored and davem330 committed Aug 13, 2016
1 parent 747ea55 commit b4c0e0c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/ipv6/calipso.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,10 @@ calipso_opt_insert(struct ipv6_opt_hdr *hop,
memcpy(new, hop, start);
ret_val = calipso_genopt((unsigned char *)new, start, buf_len, doi_def,
secattr);
if (ret_val < 0)
if (ret_val < 0) {
kfree(new);
return ERR_PTR(ret_val);
}

buf_len = start + ret_val;
/* At this point buf_len aligns to 4n, so (buf_len & 4) pads to 8n */
Expand Down

0 comments on commit b4c0e0c

Please sign in to comment.