From patchwork Tue Apr 4 13:31:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alexis_Lothor=C3=A9?= X-Patchwork-Id: 79105 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3033615vqo; Tue, 4 Apr 2023 06:36:21 -0700 (PDT) X-Google-Smtp-Source: AKy350bbgWOFBZ+/0i0QaTj6PSYriI5yn33XxZPie3Pg7ddyxNgVF79H2rlhSmMkiu5rNgebcnOP X-Received: by 2002:a62:1d41:0:b0:62a:4503:53b8 with SMTP id d62-20020a621d41000000b0062a450353b8mr2517535pfd.1.1680615381074; Tue, 04 Apr 2023 06:36:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680615381; cv=none; d=google.com; s=arc-20160816; b=yyuXtoUzlfgIxX1uDT5bf4BU/dRTJZb5EiSm7z+bFtuLU2u1AFKEk6UH2oO2SdtWnL ShvLiLt+Kve9YIxSYjEuFZWCyMTqiPEd+vufXW4eX8mtH+uQMKQz6fxnK5AOaiVi/nuT sV0scenCPJhdXshQWqNxJMPMoVBFKzQSAuniZzaB/a8VKp3pl++AXuOrKjwwtOhtllV3 OvjWsK/kFCTLRMksaTvvQPyQUMEoOeOzZf8gfnnT9ylaXqiB/lGI+frcEtNbnMn4WwIE uV4G1BgNFq155BbACDlI7J/+jX1f4iBM+bZbQx9akDRhF59N3/FB45V4HxXIDLthacid /vjw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Mo3HjqG41gQvCICstu9RcQV968d5yyBtvPhjoFmW600=; b=X/J8mcWEbt1qNOBbbVLKngNRKhDt+QwIHdQjNRYCY/oe8sO/DDg0BpRPvk2//8o9rr my/NZnbQTQ25AFCcYICTKpkYoBJCnZoARDxyOjmqAceGqdAeUjGu3vtGUSl0dg+G9C0w 7VpcgS9zyNw+278UUNeHNeIza0xo2JSMtqLrziLxxrBfRVCDbc8x2E5Uwz/dg7mFR6dZ jh3NeI59WbueTOiy7hb5BlMdj0EfkHI2XVThd6dxlIV11fSFGAIsAXu/IlYNM01FWKKa v9Yeu7XYrx/EiQHOecmFxNBBItfTIwZdXIfiSBPTjNY1krUy4GZ872P5zOVXfi3xouCe SESQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=GxlHdy4e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 199-20020a6306d0000000b004fbb61ea01dsi10511205pgg.273.2023.04.04.06.36.06; Tue, 04 Apr 2023 06:36:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=GxlHdy4e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235274AbjDDNeh (ORCPT + 99 others); Tue, 4 Apr 2023 09:34:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235237AbjDDNeY (ORCPT ); Tue, 4 Apr 2023 09:34:24 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1478649CE; Tue, 4 Apr 2023 06:33:59 -0700 (PDT) Received: (Authenticated sender: alexis.lothore@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id 6B34AE000B; Tue, 4 Apr 2023 13:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1680615238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mo3HjqG41gQvCICstu9RcQV968d5yyBtvPhjoFmW600=; b=GxlHdy4eBR/YbPceBaocXsvSxmEp3u/fxMIh5Dfb7A4Bd5lliBXi5bYo8oWgLeEEAY1IR6 1g/7+TL7i91+ve8ld8/wrQ8JExZ21LTjjzHhshte3ZXRryQqRpVJnNnjdCti5JiE/4HO7z aYCg7r9U0lFDOkcJ1azl8GuYvArkws8O682QhF2tqfvD5LB4ZSnYpZfUnRQ59Adeqk6qs+ 4g8K6YtgbypzAVxcGf/MZTx1DR4XC+CrrGkpB+M8Di1DavMH5M1SmpzeGyqDYH4fXP47ca u5D7zA7OEkzMdid0Ys2itN2N6XDwcxl9xPhOUfnw+uWSIqN8qXZdSliDFq+Bcw== From: alexis.lothore@bootlin.com To: mdf@kernel.org, hao.wu@intel.com, yilun.xu@intel.com, trix@redhat.com, russell.h.weight@intel.com, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: thomas.petazzoni@bootlin.com, nicolas.carrier@orolia.com Subject: [PATCH] fpga: bridge: properly initialize bridge device before populating children Date: Tue, 4 Apr 2023 15:31:02 +0200 Message-Id: <20230404133102.2837535-2-alexis.lothore@bootlin.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230404133102.2837535-1-alexis.lothore@bootlin.com> References: <20230404133102.2837535-1-alexis.lothore@bootlin.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762252953927407762?= X-GMAIL-MSGID: =?utf-8?q?1762252953927407762?= From: Alexis Lothoré The current code path can lead to warnings because of uninitialized device, which contains, as a consequence, uninitialized kobject. The uninitialized device is passed to of_platform_populate, which will at some point, while creating child device, try to get a reference on uninitialized parent, resulting in the following warning: kobject: '(null)' ((ptrval)): is not initialized, yet kobject_get() is being called. The warning is observed after migrating a kernel 5.10.x to 6.1.x. Reverting commit 0d70af3c2530 ("fpga: bridge: Use standard dev_release for class driver") seems to remove the warning. This commit aggregates device_initialize() and device_add() into device_register() but this new call is done AFTER of_platform_populate Fixes: 0d70af3c2530 ("fpga: bridge: Use standard dev_release for class driver") Signed-off-by: Alexis Lothoré Acked-by: Xu Yilun --- drivers/fpga/fpga-bridge.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/fpga/fpga-bridge.c b/drivers/fpga/fpga-bridge.c index 727704431f61..13918c8c839e 100644 --- a/drivers/fpga/fpga-bridge.c +++ b/drivers/fpga/fpga-bridge.c @@ -360,7 +360,6 @@ fpga_bridge_register(struct device *parent, const char *name, bridge->dev.parent = parent; bridge->dev.of_node = parent->of_node; bridge->dev.id = id; - of_platform_populate(bridge->dev.of_node, NULL, NULL, &bridge->dev); ret = dev_set_name(&bridge->dev, "br%d", id); if (ret) @@ -372,6 +371,8 @@ fpga_bridge_register(struct device *parent, const char *name, return ERR_PTR(ret); } + of_platform_populate(bridge->dev.of_node, NULL, NULL, &bridge->dev); + return bridge; error_device: