public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irqchip/mbigen: Fix incorrect null pointer check
@ 2024-01-29 13:00 Chen Jun
  2024-02-13 10:09 ` Thomas Gleixner
  2024-02-13 10:11 ` Thomas Gleixner
  0 siblings, 2 replies; 5+ messages in thread
From: Chen Jun @ 2024-01-29 13:00 UTC (permalink / raw)
  To: tglx, linux-kernel; +Cc: xuqiang36, chenjun102

bus_get_dev_root(&platform_bus_type) always returns NULL.
This makes mbigen_of_create_domain always return -ENODEV.

Fixes: fea087fc291b ("irqchip/mbigen: move to use bus_get_dev_root()")
Signed-off-by: Chen Jun <chenjun102@huawei.com>
---
 drivers/irqchip/irq-mbigen.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c
index 5101a3fb11df..58881d313979 100644
--- a/drivers/irqchip/irq-mbigen.c
+++ b/drivers/irqchip/irq-mbigen.c
@@ -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);
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] irqchip/mbigen: Fix incorrect null pointer check
  2024-01-29 13:00 [PATCH] irqchip/mbigen: Fix incorrect null pointer check Chen Jun
@ 2024-02-13 10:09 ` Thomas Gleixner
  2024-02-18  3:13   ` chenjun (AM)
  2024-02-13 10:11 ` Thomas Gleixner
  1 sibling, 1 reply; 5+ messages in thread
From: Thomas Gleixner @ 2024-02-13 10:09 UTC (permalink / raw)
  To: Chen Jun, linux-kernel; +Cc: xuqiang36, chenjun102

On Mon, Jan 29 2024 at 21:00, Chen Jun wrote:

That's not about an incorrect NULL pointer check. That's about using a
function which is guaranteed to return NULL on your platform, no?

> bus_get_dev_root(&platform_bus_type) always returns NULL.

Lacks an explanation why this always returns NULL.

Thanks

        tglx


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] irqchip/mbigen: Fix incorrect null pointer check
  2024-01-29 13:00 [PATCH] irqchip/mbigen: Fix incorrect null pointer check Chen Jun
  2024-02-13 10:09 ` Thomas Gleixner
@ 2024-02-13 10:11 ` Thomas Gleixner
  1 sibling, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2024-02-13 10:11 UTC (permalink / raw)
  To: Chen Jun, linux-kernel; +Cc: xuqiang36, chenjun102

On Mon, Jan 29 2024 at 21:00, Chen Jun wrote:
> bus_get_dev_root(&platform_bus_type) always returns NULL.
> This makes mbigen_of_create_domain always return -ENODEV.
>
> Fixes: fea087fc291b ("irqchip/mbigen: move to use bus_get_dev_root()")

Amazing that it took 9 month to figure that out ...

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] irqchip/mbigen: Fix incorrect null pointer check
  2024-02-13 10:09 ` Thomas Gleixner
@ 2024-02-18  3:13   ` chenjun (AM)
  2024-02-18 19:58     ` Thomas Gleixner
  0 siblings, 1 reply; 5+ messages in thread
From: chenjun (AM) @ 2024-02-18  3:13 UTC (permalink / raw)
  To: Thomas Gleixner, linux-kernel@vger.kernel.org; +Cc: xuqiang (M)

在 2024/2/13 18:09, Thomas Gleixner 写道:
> On Mon, Jan 29 2024 at 21:00, Chen Jun wrote:
> 
> That's not about an incorrect NULL pointer check. That's about using a
> function which is guaranteed to return NULL on your platform, no?
> 
>> bus_get_dev_root(&platform_bus_type) always returns NULL.
> 
> Lacks an explanation why this always returns NULL.
> 

Thank you for the reply.

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

So, for platform_bus_type, bus_get_dev_root always returns NULL.

> Thanks
> 
>          tglx
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] irqchip/mbigen: Fix incorrect null pointer check
  2024-02-18  3:13   ` chenjun (AM)
@ 2024-02-18 19:58     ` Thomas Gleixner
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Gleixner @ 2024-02-18 19:58 UTC (permalink / raw)
  To: chenjun (AM), linux-kernel@vger.kernel.org; +Cc: xuqiang (M)

On Sun, Feb 18 2024 at 03:13, chenjun (AM) wrote:
> 在 2024/2/13 18:09, Thomas Gleixner 写道:
>> On Mon, Jan 29 2024 at 21:00, Chen Jun wrote:
>> 
>> That's not about an incorrect NULL pointer check. That's about using a
>> function which is guaranteed to return NULL on your platform, no?
>> 
>>> bus_get_dev_root(&platform_bus_type) always returns NULL.
>> 
>> Lacks an explanation why this always returns NULL.
>> 
>
> Thank you for the reply.
>
> bus_get_dev_root returns sp->dev_root set in subsys_register.
> And subsys_register is not called by platform_bus_init.
>
> So, for platform_bus_type, bus_get_dev_root always returns NULL.

Please add this information to the change log.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-02-18 19:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-29 13:00 [PATCH] irqchip/mbigen: Fix incorrect null pointer check Chen Jun
2024-02-13 10:09 ` Thomas Gleixner
2024-02-18  3:13   ` chenjun (AM)
2024-02-18 19:58     ` Thomas Gleixner
2024-02-13 10:11 ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox