On Mon, 2016-11-14 at 14:02 +0100, Phil Sutter wrote: > The idea for this was born when testing VF support in iproute2 which was > impeded by hardware requirements. In fact, not every VF-capable hardware > driver implements all netdev ops, so testing the interface is still hard > to do even with a well-sorted hardware shelf. > ... > static int dummy_dev_init(struct net_device *dev) > { > + struct dummy_priv *priv = netdev_priv(dev); > + > dev->dstats = netdev_alloc_pcpu_stats(struct pcpu_dstats); > if (!dev->dstats) > return -ENOMEM; > > + priv->num_vfs = num_vfs; > + priv->vfinfo = NULL; > + > + if (!num_vfs) > + return 0; > + > + priv->vfinfo = kcalloc(num_vfs, sizeof(struct vf_data_storage), > + GFP_KERNEL); > + if (!priv->vfinfo) > + return -ENOMEM;
You must free dev->dstats here, otherwise kernel memory will leak. > + > return 0; > } >