WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] Unmatched decrementing of net device reference c

To: Glauber de Oliveira Costa <gcosta@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] Unmatched decrementing of net device reference count
From: Herbert Xu <herbert.xu@xxxxxxxxxx>
Date: Thu, 21 Dec 2006 19:49:32 +1100
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 21 Dec 2006 00:49:34 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20061220132151.GA7900@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20061219153755.GD19551@xxxxxxxxxx> <E1Gwoqk-00051M-00@xxxxxxxxxxxxxxxxxxxxxxxx> <20061220132151.GA7900@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.9i
On Wed, Dec 20, 2006 at 11:21:51AM -0200, Glauber de Oliveira Costa wrote:
> 
> unregister_netdev() works as a barrier in this case. The call to
> netif_disconnect_backend() introduces a new carrier watch, which hold()s a
> reference to be put()'d in a future time. If we call free right after that, 
> it might be the case that put() is called after free. Nothing in this
> case prevents this memory region to have been allocated again to another
> device. 

Thanks for the explanation.  I understand the problem now.  However,
I think your patch isn't adequate because the closing of the backend
no longer shuts down the transmitter in the frontend.

Looking at this again it comes down to an asymmetry in the setup
and tear-down processes.  On startup, we have two stages:

1) netfront_probe => create_netdev
                  => open_netdev => register_netdev;
2) network_connect => sets up IRQ/ring buffer/etc.

On tear-down, things occur in the wrong order:

1) netfront_closing => close_netdev => unregister_netdev;
2) netfront_remove => kills IRQ/ring buffer and free_netdev.

The tear-down order should be the opposite of the setup, i.e.,

1) netfront_closing => kills IRQ/ring buffer;
2) netfront_remove => close_netdev => unregister_netdev
                   => free_netdev.

So I suggest we move the netif_disconnct_backend call to
netfront_closing and close_netdev to netfront_remove.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel