From: Dan Carpenter Date: Wed, 7 Jul 2021 10:01:00 +0000 (+0300) Subject: sock: unlock on error in sock_setsockopt() X-Git-Tag: baikal/aarch64/sdk6.1~6205^2~33 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=6d0306dfd9a57743354691e76a1ed40c704a2090;p=kernel.git sock: unlock on error in sock_setsockopt() If copy_from_sockptr() then we need to unlock before returning. Fixes: e9964564dc86 ("net: sock: extend SO_TIMESTAMPING for PHC binding") Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller --- diff --git a/net/core/sock.c b/net/core/sock.c index 1c4b0468bc2c3..a3eea6e0b30a7 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1123,8 +1123,10 @@ set_sndbuf: case SO_TIMESTAMPING_OLD: if (optlen == sizeof(timestamping)) { if (copy_from_sockptr(×tamping, optval, - sizeof(timestamping))) - return -EFAULT; + sizeof(timestamping))) { + ret = -EFAULT; + break; + } } else { memset(×tamping, 0, sizeof(timestamping)); timestamping.flags = val;