Subject: Re: [RFC 1/3] cfg80211/nl80211 core

From: Johannes Berg <[email-masked]>
Date: Fri, 06 Oct 2006 11:51:07 +0200

On Thu, 2006-09-14 at 12:49 +0200, Johannes Berg wrote:

> +struct cfg80211_registered_driver *
> +cfg80211_get_drv_from_ifindex(int ifindex)
> +{
> +	struct cfg80211_registered_driver *drv;
> +	struct net_device *dev;
> +
> +	mutex_lock(&cfg80211_drv_mutex);
> +	dev = dev_get_by_index(ifindex);
> +	if (!dev)
> +		return ERR_PTR(-ENODEV);
> +	drv = cfg80211_drv_by_priv(dev->ieee80211_ptr);
> +	if (drv)
> +		mutex_lock(&drv->mtx);
> +	dev_put(dev);
> +	if (drv)
> +		return drv;
> +	return ERR_PTR(-ENODEV);
> +}

So... nobody spotted the "obvious" [1] locking problem here ;) fixed,
will update the patches soon and upload somewhere, netdev doesn't like
them and drops my mail (even 0/3 which wasn't that big).

johannes

[1] hint: drv->mtx is supposed to be left locked at the end, but
cfg80211_drv_mutex isn't :) I found out the hard way when testing my WE
backward compat code