Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9088122pxu; Mon, 28 Dec 2020 06:20:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzY0YgOqxaggY1eQa/UEttMlPYhzdqWbgvy4kFzqEp/zF1h1UmjjBOJ7IxVFovC6jDslfwE X-Received: by 2002:a50:cd9c:: with SMTP id p28mr41402810edi.83.1609165229087; Mon, 28 Dec 2020 06:20:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165229; cv=none; d=google.com; s=arc-20160816; b=Agup2zOPgHm3onE1rVBqF2vFpx5582wABhxQ+6eP30+5528s9nW/ZCAI+Qinvc6Lux CtYqAIEtPuMJ8VofY5BkNdJlI1qQPFA1Aw3EO/0XIikj9CUHQyeVoJ99/cYLYt4e9DGA CWNMSqWVsxkQm5YsnS/xbsYLEJi6JhbmeASknJ7KylYDuDbxduK/sa/c0+3wsztHK4WZ xc9MNlKiAg7nQjQIQnJZtYVDpy8eAEybz5ZS7BRtqNJpHIFTxp+BUPlS6sD7bNjeOxgz W3wJnERVqmf+5yQLDdsLECswsP3Tv7DmvyVabRXfzEpXlix4Xf4fZSFHHq8TPqnWmC+W ineA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YEDyolOl/q0Qb3GiCmJvWgK0J/7VS+5hufQhgoOjavc=; b=Ht7hGw+qSMXG8jS0Bt6aNIpHcSU6LS+AljmzpZey7EVRirVjXek2xTpiEs6oVlMGYn cY1cnxmz9JWq6f3yntGQ/uegnCF5mZwqstLaWFTYX2LsWM9PM8dyrgHsrv5BhQdJd+nm Sl+0EUM+ai7GVul3FOE82gn7ig4H6oKBBrJXnhKwojI86ok7E0jmq0/Mo4XYf2KD/G1d uPdOdja5720rdOgS3Cq8NaiQukY80m69fOAdfm39y7iqTO1L1IHOHWhftScV5wJVxAJC iM9WekzvsuMpPHK28/RMmRn/OPQZq7K230NvfFTgErnLYOk9j3KbyP1gar+2tnN3H57h SCMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Gqx0lbo3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d17si17975960eja.318.2020.12.28.06.20.06; Mon, 28 Dec 2020 06:20:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Gqx0lbo3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2501938AbgL1OSX (ORCPT + 99 others); Mon, 28 Dec 2020 09:18:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:53490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436558AbgL1OSW (ORCPT ); Mon, 28 Dec 2020 09:18:22 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 189A4207A9; Mon, 28 Dec 2020 14:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165061; bh=gGlTvwms0ABlxOyMUc92MnLMqf2nz9B+jnLhNrOlwnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gqx0lbo3OHqZd8P6h+1u2xQ1ckE6lCHDu3Hl3q6toskbGJX+iykrIhWQa8JihZrdj itOBvoomkTY0J2c1p78vCDV4dwgVxCxLNMoKp0B3W6eb8uqIGl9gSqYcccJb6Hhf8f QlrmYNWRZEVuw6gOvWf8dBN+sxOwYfh30/s0QiPg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leon Romanovsky , Jack Morgenstein , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.10 396/717] RDMA/core: Do not indicate device ready when device enablement fails Date: Mon, 28 Dec 2020 13:46:34 +0100 Message-Id: <20201228125039.971185678@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jack Morgenstein [ Upstream commit 779e0bf47632c609c59f527f9711ecd3214dccb0 ] In procedure ib_register_device, procedure kobject_uevent is called (advertising that the device is ready for userspace usage) even when device_enable_and_get() returned an error. As a result, various RDMA modules attempted to register for the device even while the device driver was preparing to unregister the device. Fix this by advertising the device availability only after enabling the device succeeds. Fixes: e7a5b4aafd82 ("RDMA/device: Don't fire uevent before device is fully initialized") Link: https://lore.kernel.org/r/20201208073545.9723-3-leon@kernel.org Suggested-by: Leon Romanovsky Signed-off-by: Jack Morgenstein Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/device.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index a3b1fc84cdcab..4a041511b70ec 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -1374,9 +1374,6 @@ int ib_register_device(struct ib_device *device, const char *name, } ret = enable_device_and_get(device); - dev_set_uevent_suppress(&device->dev, false); - /* Mark for userspace that device is ready */ - kobject_uevent(&device->dev.kobj, KOBJ_ADD); if (ret) { void (*dealloc_fn)(struct ib_device *); @@ -1396,8 +1393,12 @@ int ib_register_device(struct ib_device *device, const char *name, ib_device_put(device); __ib_unregister_device(device); device->ops.dealloc_driver = dealloc_fn; + dev_set_uevent_suppress(&device->dev, false); return ret; } + dev_set_uevent_suppress(&device->dev, false); + /* Mark for userspace that device is ready */ + kobject_uevent(&device->dev.kobj, KOBJ_ADD); ib_device_put(device); return 0; -- 2.27.0