Received: by 10.223.185.116 with SMTP id b49csp6356537wrg; Wed, 28 Feb 2018 08:06:09 -0800 (PST) X-Google-Smtp-Source: AH8x226LPJf2Ju9isyZeHal/DSo0WmDN4WYxCq9kgrt+EQBRqWTybbi/OidlhuxlqQsj7k/3BV6/ X-Received: by 2002:a17:902:7789:: with SMTP id o9-v6mr18862510pll.422.1519833969123; Wed, 28 Feb 2018 08:06:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519833969; cv=none; d=google.com; s=arc-20160816; b=xOWhJN6dKbUBAOih9Qg5iThlzsLXZ8QLkeBpJUn+e2DcIHj6mt5QmdQUAqGsEwzYCW EChci8RWqQSEMpUQFYFdFUH/ryxzpm8Oaznll3atdhW/5iKPGGU8jMw2AnD1IUqLSBC2 PhSh5ixM9gf4oUGNiz5rXqFH9lT2c3vJYjqj0AO5ks0HIZQkAEy0wmZ97xzDwowPKcuN rnECE4Fuf67kq8nM/57b0ftWzq8ewxyAVRCVxIY0GmehOn3WO270/rP1FuwJpwpFsZyZ i6FBcT1yy6wTGF6PNqSYsjvTXSlen+Y+RxTUJ1EAwL2IsJ2erJF74T29S53XYe8nAUCP gHrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=M168I81I2hakrIuHHoNLYQAaXzk9JajDZsWWn8380d8=; b=07nj/VyX72g6tyQ9/iCPuY3lImd66dlrQaTnC9KOKYHo7/T1on55m2vWfeepuJvsAh 6mH6AZQ2EXu5Y6vGFS3+KqFnr0kDmDSDZHh55dnH5XK19b9Id5cQ3iKZ17F5Zrq2TXYV Bt3/hZJd5b9WhRiAQ7PQtsSVjvm2fWIoFGenGbUxMLW9LwrCfLp6jnlwbkLs9wZLD3cI +2fsjf/iY7BzmYGUcandKmLZgvgdJMit+kwG6ZiWzcq9ldj7J901lJd6DYQBYLO33SHl r7q189bjUjHIWu10i7pDbuTmgFCkTh/XsaNuTT2weozeMdBXGezfQZMpKPgWvpN7wVKG wjAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h14si1361656pfd.404.2018.02.28.08.05.54; Wed, 28 Feb 2018 08:06:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934407AbeB1QEi (ORCPT + 99 others); Wed, 28 Feb 2018 11:04:38 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34833 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932767AbeB1QEe (ORCPT ); Wed, 28 Feb 2018 11:04:34 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yu-0006Xb-DC; Wed, 28 Feb 2018 15:22:32 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Ye-0008Pz-6e; Wed, 28 Feb 2018 15:22:16 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "weiping zhang" , "weiping zhang" , "Michael S. Tsirkin" , "Cornelia Huck" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 045/254] virtio: release virtio index when fail to device_register In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: weiping zhang commit e60ea67bb60459b95a50a156296041a13e0e380e upstream. index can be reused by other virtio device. Signed-off-by: weiping zhang Reviewed-by: Cornelia Huck Signed-off-by: Michael S. Tsirkin Signed-off-by: Ben Hutchings --- drivers/virtio/virtio.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/virtio/virtio.c +++ b/drivers/virtio/virtio.c @@ -223,6 +223,8 @@ int register_virtio_device(struct virtio /* 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) add_status(dev, VIRTIO_CONFIG_S_FAILED);