net: fix sock_timestamping_bind_phc() to release device
authorMiroslav Lichvar <mlichvar@redhat.com>
Tue, 11 Jan 2022 15:10:53 +0000 (16:10 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 11:03:01 +0000 (12:03 +0100)
commit 2a4d75bfe41232608f5596a6d1369f92ccb20817 upstream.

Don't forget to release the device in sock_timestamping_bind_phc() after
it was used to get the vclock indices.

Fixes: d463126e23f1 ("net: sock: extend SO_TIMESTAMPING for PHC binding")
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Cc: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/core/sock.c

index 41e91d0f7061452b3239325a7af8030336c8d2a7..7de234693a3bf53d320cef0f2e5fde988188c2dd 100644 (file)
@@ -843,6 +843,8 @@ static int sock_timestamping_bind_phc(struct sock *sk, int phc_index)
        }
 
        num = ethtool_get_phc_vclocks(dev, &vclock_index);
+       dev_put(dev);
+
        for (i = 0; i < num; i++) {
                if (*(vclock_index + i) == phc_index) {
                        match = true;