Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754520Ab2KIEpf (ORCPT ); Thu, 8 Nov 2012 23:45:35 -0500 Received: from ozlabs.org ([203.10.76.45]:45081 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752333Ab2KIEpe (ORCPT ); Thu, 8 Nov 2012 23:45:34 -0500 From: Rusty Russell To: Cornelia Huck , "Michael S. Tsirkin" Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] virtio: Don't access index after unregister. In-Reply-To: <1352371427-32363-1-git-send-email-cornelia.huck@de.ibm.com> References: <1352371427-32363-1-git-send-email-cornelia.huck@de.ibm.com> User-Agent: Notmuch/0.14 (http://notmuchmail.org) Emacs/23.4.1 (i686-pc-linux-gnu) Date: Fri, 09 Nov 2012 14:54:50 +1030 Message-ID: <877gpv2yjx.fsf@rustcorp.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1032 Lines: 32 Cornelia Huck writes: > Virtio wants to release used indices after the corresponding > virtio device has been unregistered. However, virtio does not > hold an extra reference, giving up its last reference with > device_unregister(), making accessing dev->index afterwards > invalid. > > I actually saw problems when testing my (not-yet-merged) > virtio-ccw code: > > - device_add virtio-net,id=xxx > -> creates device virtio with n>0 > > - device_del xxx > -> deletes virtio, but calls ida_simple_remove with an > index of 0 > > - device_add virtio-net,id=xxx > -> tries to add virtio0, which is still in use... > > So let's save the index we want to release before calling > device_unregister(). Great catch! I've add a CC:stable. Applied, Rusty. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/