if (dev->priv) { kfree(dev->priv); dev->priv = NULL; } 
kfree(dev->priv); dev->priv = NULL; 
static int wanrouter_device_new_if(struct wan_device *wandev,				   wanif_conf_t __user *u_conf){	wanif_conf_t *cnf;	struct net_device *dev = NULL;#ifdef CONFIG_WANPIPE_MULTPPP	struct ppp_device *pppdev=NULL;#endif	int err;	if ((wandev->state == WAN_UNCONFIGURED) || (wandev->new_if == NULL))		return -ENODEV;	cnf = kmalloc(sizeof(wanif_conf_t), GFP_KERNEL);	if (!cnf)		return -ENOBUFS;	err = -EFAULT;	if (copy_from_user(cnf, u_conf, sizeof(wanif_conf_t)))		goto out;	err = -EINVAL;	if (cnf->magic != ROUTER_MAGIC)		goto out;	if (cnf->config_id == WANCONFIG_MPPP) {#ifdef CONFIG_WANPIPE_MULTPPP		pppdev = kmalloc(sizeof(struct ppp_device), GFP_KERNEL);		err = -ENOBUFS;		if (pppdev == NULL)			goto out;		memset(pppdev, 0, sizeof(struct ppp_device));		pppdev->dev = kmalloc(sizeof(struct net_device), GFP_KERNEL);		if (pppdev->dev == NULL) {			kfree(pppdev);			err = -ENOBUFS;			goto out;		}		memset(pppdev->dev, 0, sizeof(struct net_device));		err = wandev->new_if(wandev, (struct net_device *)pppdev, cnf);		dev = pppdev->dev;#else		printk(KERN_INFO "%s: Wanpipe Mulit-Port PPP support has not been compiled in!\n",				wandev->name);		err = -EPROTONOSUPPORT;		goto out;#endif	} else {		dev = kmalloc(sizeof(struct net_device), GFP_KERNEL);		err = -ENOBUFS;		if (dev == NULL)			goto out;		memset(dev, 0, sizeof(struct net_device));		err = wandev->new_if(wandev, dev, cnf);	}	if (!err) {		/* Register network interface. This will invoke init()		 * function supplied by the driver.  If device registered		 * successfully, add it to the interface list.		 */		if (dev->name == NULL) {			err = -EINVAL;		} else {			#ifdef WANDEBUG			printk(KERN_INFO "%s: registering interface %s...\n",				wanrouter_modname, dev->name);			#endif			err = register_netdev(dev);			if (!err) {				struct net_device *slave = NULL;				unsigned long smp_flags=0;				lock_adapter_irq(&wandev->lock, &smp_flags);				if (wandev->dev == NULL) {					wandev->dev = dev;				} else {					for (slave=wandev->dev;					 *((struct net_device **)slave->priv);				 slave = *((struct net_device **)slave->priv));				     *((struct net_device **)slave->priv) = dev;				}				++wandev->ndev;				unlock_adapter_irq(&wandev->lock, &smp_flags);				err = 0;	/* done !!! */				goto out;			}		}		if (wandev->del_if)			wandev->del_if(wandev, dev);	}	/* This code has moved from del_if() function */	if (dev->priv) {		kfree(dev->priv);		dev->priv = NULL;	}#ifdef CONFIG_WANPIPE_MULTPPP	if (cnf->config_id == WANCONFIG_MPPP)		kfree(pppdev);	else		kfree(dev);#else	/* Sync PPP is disabled */	if (cnf->config_id != WANCONFIG_MPPP)		kfree(dev);#endifout:	kfree(cnf);	return err;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/a51482bde22f99c63fbbb57d5d46cc666384e379/wanmain.c/buggy/net/wanrouter/wanmain.c