From: Paolo Abeni <pabeni@xxxxxxxxxx> commit a74762675f700a5473ebe54a671a0788a5b23cc9 upstream. The mptcp_get_int_option() helper is needless open-coded in a couple of places, replace the duplicate code with the helper call. Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx> Reviewed-by: Mat Martineau <martineau@xxxxxxxxxx> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@xxxxxxxxxx> Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx> Stable-dep-of: bd11dc4fb969 ("mptcp: fix full TCP keep-alive support") Signed-off-by: Matthieu Baerts (NGI0) <matttbe@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- net/mptcp/sockopt.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -621,13 +621,11 @@ static int mptcp_setsockopt_sol_tcp_cork { struct mptcp_subflow_context *subflow; struct sock *sk = (struct sock *)msk; - int val; + int val, ret; - if (optlen < sizeof(int)) - return -EINVAL; - - if (copy_from_sockptr(&val, optval, sizeof(val))) - return -EFAULT; + ret = mptcp_get_int_option(msk, optval, optlen, &val); + if (ret) + return ret; lock_sock(sk); sockopt_seq_inc(msk); @@ -651,13 +649,11 @@ static int mptcp_setsockopt_sol_tcp_node { struct mptcp_subflow_context *subflow; struct sock *sk = (struct sock *)msk; - int val; - - if (optlen < sizeof(int)) - return -EINVAL; + int val, ret; - if (copy_from_sockptr(&val, optval, sizeof(val))) - return -EFAULT; + ret = mptcp_get_int_option(msk, optval, optlen, &val); + if (ret) + return ret; lock_sock(sk); sockopt_seq_inc(msk); Patches currently in stable-queue which might be from kroah.com@xxxxxxxxxxxxxxx are queue-6.1/mptcp-fix-full-tcp-keep-alive-support.patch queue-6.1/mptcp-cleanup-sol_tcp-handling.patch queue-6.1/mptcp-avoid-some-duplicate-code-in-socket-option-handling.patch