From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:50216 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751781AbdK2Nzr (ORCPT ); Wed, 29 Nov 2017 08:55:47 -0500 Date: Wed, 29 Nov 2017 15:55:45 +0200 From: "Michael S. Tsirkin" To: weiping zhang Cc: jasowang@redhat.com, virtualization@lists.linux-foundation.org, stable@vger.kernel.org Subject: Re: [PATCH] virtio: release virtio index when fail to device_register Message-ID: <20171129155501-mutt-send-email-mst@kernel.org> References: <20171129012301.GA6637@localhost.didichuxing.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171129012301.GA6637@localhost.didichuxing.com> Sender: stable-owner@vger.kernel.org List-ID: On Wed, Nov 29, 2017 at 09:23:01AM +0800, weiping zhang wrote: > index can be reused by other virtio device. > > Signed-off-by: weiping zhang Thanks! I've queued this up, this is needed on stable as well. > --- > drivers/virtio/virtio.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c > index 48230a5..bf7ff39 100644 > --- a/drivers/virtio/virtio.c > +++ b/drivers/virtio/virtio.c > @@ -333,6 +333,8 @@ int register_virtio_device(struct virtio_device *dev) > /* device_register() causes the bus infrastructure to look for a > * matching driver. */ > err = device_register(&dev->dev); > + if (err) > + ida_simple_remove(&virtio_index_ida, dev->index); > out: > if (err) > virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED); > -- > 2.9.4