2024-06-27, 15:08:33 +0200, Antonio Quartulli wrote:
quoted hunk ↗ jump to hunk
@@ -46,6 +46,17 @@ static int ovpn_struct_init(struct net_device *dev, enum ovpn_mode mode)
ovpn->mode = mode;
spin_lock_init(&ovpn->lock);
+ if (mode == OVPN_MODE_MP) {
+ /* the peer container is fairly large, therefore we dynamically
+ * allocate it only when needed
+ */
+ ovpn->peers = kzalloc(sizeof(*ovpn->peers), GFP_KERNEL);
+ if (!ovpn->peers)
+ return -ENOMEM;
As we discussed in v3 (it was about the workqueue), I don't think this
will get freed correctly in some of the failure cases. This should go
in ovpn_net_init.
+
+ spin_lock_init(&ovpn->peers->lock);
+ }
+
return 0;
}
--
Sabrina