diff options
author | Vlad Yasevich <vladislav.yasevich@hp.com> | 2007-05-23 11:11:37 -0400 |
---|---|---|
committer | Vladislav Yasevich <vxy@hera.kernel.org> | 2007-06-13 16:44:41 -0400 |
commit | fe979ac169970b3d12facd6565766735862395c5 (patch) | |
tree | 970e7093b9a86f9c6903871100a10faf62168a58 /net/sctp | |
parent | 8b35805693e1915829355723537f99f1b8bc9cc0 (diff) |
[SCTP] Fix leak in sctp_getsockopt_local_addrs when copy_to_user fails
If the copy_to_user or copy_user calls fail in sctp_getsockopt_local_addrs(),
the function should free locally allocated storage before returning error.
Spotted by Coverity.
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
Acked-by: Sridhar Samudrala <sri@us.ibm.com>
Diffstat (limited to 'net/sctp')
-rw-r--r-- | net/sctp/socket.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index a5b6e559451e..45510c46c223 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -4352,11 +4352,12 @@ copy_getaddrs: | |||
4352 | err = -EFAULT; | 4352 | err = -EFAULT; |
4353 | goto error; | 4353 | goto error; |
4354 | } | 4354 | } |
4355 | if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num)) | 4355 | if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num)) { |
4356 | return -EFAULT; | 4356 | err = -EFAULT; |
4357 | goto error; | ||
4358 | } | ||
4357 | if (put_user(bytes_copied, optlen)) | 4359 | if (put_user(bytes_copied, optlen)) |
4358 | return -EFAULT; | 4360 | err = -EFAULT; |
4359 | |||
4360 | error: | 4361 | error: |
4361 | kfree(addrs); | 4362 | kfree(addrs); |
4362 | return err; | 4363 | return err; |