diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 5681ce3aebca05f5fbfd4e5ba194f8cdd14fc3ba..a78d962e2c7073ccd1827c21f2a03750f4ee75e8 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -88,7 +88,7 @@ struct netlink_sock {
 
 static inline struct netlink_sock *nlk_sk(struct sock *sk)
 {
-	return (struct netlink_sock *)sk;
+	return container_of(sk, struct netlink_sock, sk);
 }
 
 struct nl_pid_hash {