Skip to contentSkip to conversation

irqchip/mbigen: Fix incorrect null pointer check

PATCH In review 陈骏 3 participants 3 messages Feb 19, 2024 irqchip drivers

lore
Share & tools
lore

陈骏

author
#0 lore raw

PATCH v2 1/1 irqchip/mbigen: Fix incorrect null pointer check

From: Chen Jun <[email protected]>

bus_get_dev_root returns sp->dev_root set in subsys_register. And subsys_register is not called by platform_bus_init.

For platform_bus_type, bus_get_dev_root always returns NULL. This makes mbigen_of_create_domain always return -ENODEV.

Fixes fea087fc291b ("irqchip/mbigen: move to use bus_get_dev_root()")

---
v2: Modify change log
v1: https://lore.kernel.org/all/[email protected]/

 drivers/irqchip/irq-mbigen.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/irqchip/irq-mbigen.c +1 -7
index 5101a3fb11df..58881d313979 100644
@@ -235,22 +235,17 @@ static const struct irq_domain_ops mbigen_domain_ops = {
 static int mbigen_of_create_domain(struct platform_device *pdev,
 				   struct mbigen_device *mgn_chip)
 {
-	struct device *parent;
 	struct platform_device *child;
 	struct irq_domain *domain;
 	struct device_node *np;
 	u32 num_pins;
 	int ret = 0;
 
-	parent = bus_get_dev_root(&platform_bus_type);
-	if (!parent)
-		return -ENODEV;
-
 	for_each_child_of_node(pdev->dev.of_node, np) {
 		if (!of_property_read_bool(np, "interrupt-controller"))
 			continue;
 
-		child = of_platform_device_create(np, NULL, parent);
+		child = of_platform_device_create(np, NULL, NULL);
 		if (!child) {
 			ret = -ENOMEM;
 			break;
@@ -273,7 +268,6 @@ static int mbigen_of_create_domain(struct platform_device *pdev,
 		}
 	}
 
-	put_device(parent);
 	if (ret)
 		of_node_put(np);
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 11 lines · 陈骏

From: Chen Jun <[email protected]>

bus_get_dev_root returns sp->dev_root set in subsys_register. And subsys_register is not called by platform_bus_init.

For platform_bus_type, bus_get_dev_root always returns NULL. This makes mbigen_of_create_domain always return -ENODEV.

Fixes fea087fc291b ("irqchip/mbigen: move to use bus_get_dev_root()")

---

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documentation/process/stable-kernel-rules.rst file for how to resolve this.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot

#2 lore raw
In reply to 陈骏

Chen!

Quoted 1 line · 陈骏

From: Chen Jun <[email protected]>

As I said before, the subject line does not make sense. This is not about an incorrect NULL pointer check. It's about using a function which is guaranteed to return NULL on your platform. Something like:

irqchip/mbigen: Don't use bus_get_dev_root() to find the parent

makes it pretty clear what this is about.

Quoted 2 lines

bus_get_dev_root returns sp->dev_root set in subsys_register. And subsys_register is not called by platform_bus_init.

Please use '()' when referencing functions. See:

https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#function-references-in-changelogs

Quoted 2 lines

For platform_bus_type, bus_get_dev_root always returns NULL. This makes mbigen_of_create_domain always return -ENODEV.

This lacks an information how the above problem is solved, i.e. something like:

Don't try to retrieve the parent via bus_get_dev_root() and unconditionally hand a NULL pointer to of_platform_device_create() to fix this.

Hmm?

Quoted 2 lines
Fixes fea087fc291b ("irqchip/mbigen: move to use bus_get_dev_root()")

Needs a

under the Signed-off-by tag.

Thanks,

tglx