]> git.baikalelectronics.ru Git - kernel.git/commitdiff
sock: unlock on error in sock_setsockopt()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 7 Jul 2021 10:01:00 +0000 (13:01 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 8 Jul 2021 03:49:12 +0000 (20:49 -0700)
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 <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/sock.c

index 1c4b0468bc2c301cecde6e8e0ceaab1631232cb7..a3eea6e0b30a7d43793f567ffa526092c03e3546 100644 (file)
@@ -1123,8 +1123,10 @@ set_sndbuf:
        case SO_TIMESTAMPING_OLD:
                if (optlen == sizeof(timestamping)) {
                        if (copy_from_sockptr(&timestamping, optval,
-                                             sizeof(timestamping)))
-                               return -EFAULT;
+                                             sizeof(timestamping))) {
+                               ret = -EFAULT;
+                               break;
+                       }
                } else {
                        memset(&timestamping, 0, sizeof(timestamping));
                        timestamping.flags = val;