All of lore.kernel.org
 help / color / mirror / Atom feed
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	[thread overview]
Message-ID: <20230404133102.2837535-2-alexis.lothore@bootlin.com> (raw)
In-Reply-To: <20230404133102.2837535-1-alexis.lothore@bootlin.com>

From: Alexis Lothoré <alexis.lothore@bootlin.com>

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é <alexis.lothore@bootlin.com>
---
 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:
-- 
2.40.0


  reply	other threads:[~2023-04-04 13:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-04 13:31 [PATCH 0/1] warning on FPGA bridge registration alexis.lothore
2023-04-04 13:31 ` alexis.lothore [this message]
2023-04-06 16:04   ` [PATCH] fpga: bridge: properly initialize bridge device before populating children Xu Yilun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230404133102.2837535-2-alexis.lothore@bootlin.com \
    --to=alexis.lothore@bootlin.com \
    --cc=hao.wu@intel.com \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdf@kernel.org \
    --cc=nicolas.carrier@orolia.com \
    --cc=russell.h.weight@intel.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=trix@redhat.com \
    --cc=yilun.xu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.