Commit fe979ac1 authored by Vlad Yasevich's avatar Vlad Yasevich Committed by Vladislav Yasevich

[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: default avatarVlad Yasevich <vladislav.yasevich@hp.com>
Acked-by: default avatarSridhar Samudrala <sri@us.ibm.com>
parent 8b358056
...@@ -4352,11 +4352,12 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len, ...@@ -4352,11 +4352,12 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len,
err = -EFAULT; err = -EFAULT;
goto error; goto error;
} }
if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num)) if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num)) {
return -EFAULT; err = -EFAULT;
goto error;
}
if (put_user(bytes_copied, optlen)) if (put_user(bytes_copied, optlen))
return -EFAULT; err = -EFAULT;
error: error:
kfree(addrs); kfree(addrs);
return err; return err;
......
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