2020-12-13 02:45:55

by Saravana Kannan

[permalink] [raw]
Subject: [PATCH] ACPI: Use fwnode_init() to set up fwnode

Commit 01bb86b380a3 ("driver core: Add fwnode_init()") was supposed to
fix up all instances of fwnode creation to use fwnode_init(). But looks
like this instance was missed. This causes a NULL pointer dereference
during device_add() [1]. So, fix it.

[ 60.792324][ T1] Call trace:
[ 60.795495][ T1] device_add+0xf60/0x16b0
__fw_devlink_link_to_consumers at drivers/base/core.c:1583
(inlined by) fw_devlink_link_device at drivers/base/core.c:1726
(inlined by) device_add at drivers/base/core.c:3088
[ 60.799813][ T1] platform_device_add+0x274/0x628
[ 60.804833][ T1] acpi_iort_init+0x9d8/0xc50
[ 60.809415][ T1] acpi_init+0x45c/0x4e8
[ 60.813556][ T1] do_one_initcall+0x170/0xb70
[ 60.818224][ T1] kernel_init_freeable+0x6a8/0x734
[ 60.823332][ T1] kernel_init+0x18/0x12c
[ 60.827566][ T1] ret_from_fork+0x10/0x1c
[ 60.838756][ T1] ---[ end trace fa5c8ce17a226d83 ]---

[1] - https://lore.kernel.org/linux-arm-kernel/[email protected]/
Fixes: 01bb86b380a3 ("driver core: Add fwnode_init()")
Reported-by: Qian Cai <[email protected]>
Suggested-by: Robin Murphy <[email protected]>
Tested-by: Marc Zyngier <[email protected]>
Signed-off-by: Saravana Kannan <[email protected]>
---
Greg,

Can you please pull this into driver-core-next since the commit that
causes this is only present in driver-core-next?

-Saravana

include/linux/acpi.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index 39263c6b52e1..2630c2e953f7 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -55,7 +55,7 @@ static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
if (!fwnode)
return NULL;

- fwnode->ops = &acpi_static_fwnode_ops;
+ fwnode_init(fwnode, &acpi_static_fwnode_ops);

return fwnode;
}
--
2.29.2.576.ga3fc446d84-goog


2020-12-13 02:50:29

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] ACPI: Use fwnode_init() to set up fwnode

On Friday, December 11, 2020 9:26:29 PM CET Saravana Kannan wrote:
> Commit 01bb86b380a3 ("driver core: Add fwnode_init()") was supposed to
> fix up all instances of fwnode creation to use fwnode_init(). But looks
> like this instance was missed. This causes a NULL pointer dereference
> during device_add() [1]. So, fix it.
>
> [ 60.792324][ T1] Call trace:
> [ 60.795495][ T1] device_add+0xf60/0x16b0
> __fw_devlink_link_to_consumers at drivers/base/core.c:1583
> (inlined by) fw_devlink_link_device at drivers/base/core.c:1726
> (inlined by) device_add at drivers/base/core.c:3088
> [ 60.799813][ T1] platform_device_add+0x274/0x628
> [ 60.804833][ T1] acpi_iort_init+0x9d8/0xc50
> [ 60.809415][ T1] acpi_init+0x45c/0x4e8
> [ 60.813556][ T1] do_one_initcall+0x170/0xb70
> [ 60.818224][ T1] kernel_init_freeable+0x6a8/0x734
> [ 60.823332][ T1] kernel_init+0x18/0x12c
> [ 60.827566][ T1] ret_from_fork+0x10/0x1c
> [ 60.838756][ T1] ---[ end trace fa5c8ce17a226d83 ]---
>
> [1] - https://lore.kernel.org/linux-arm-kernel/[email protected]/
> Fixes: 01bb86b380a3 ("driver core: Add fwnode_init()")
> Reported-by: Qian Cai <[email protected]>
> Suggested-by: Robin Murphy <[email protected]>
> Tested-by: Marc Zyngier <[email protected]>
> Signed-off-by: Saravana Kannan <[email protected]>

Acked-by: Rafael J. Wysocki <[email protected]>

> ---
> Greg,
>
> Can you please pull this into driver-core-next since the commit that
> causes this is only present in driver-core-next?
>
> -Saravana
>
> include/linux/acpi.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 39263c6b52e1..2630c2e953f7 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -55,7 +55,7 @@ static inline struct fwnode_handle *acpi_alloc_fwnode_static(void)
> if (!fwnode)
> return NULL;
>
> - fwnode->ops = &acpi_static_fwnode_ops;
> + fwnode_init(fwnode, &acpi_static_fwnode_ops);
>
> return fwnode;
> }
>




2020-12-13 15:05:19

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] ACPI: Use fwnode_init() to set up fwnode

On Fri, Dec 11, 2020 at 09:53:09PM +0100, Rafael J. Wysocki wrote:
> On Friday, December 11, 2020 9:26:29 PM CET Saravana Kannan wrote:
> > Commit 01bb86b380a3 ("driver core: Add fwnode_init()") was supposed to
> > fix up all instances of fwnode creation to use fwnode_init(). But looks
> > like this instance was missed. This causes a NULL pointer dereference
> > during device_add() [1]. So, fix it.
> >
> > [ 60.792324][ T1] Call trace:
> > [ 60.795495][ T1] device_add+0xf60/0x16b0
> > __fw_devlink_link_to_consumers at drivers/base/core.c:1583
> > (inlined by) fw_devlink_link_device at drivers/base/core.c:1726
> > (inlined by) device_add at drivers/base/core.c:3088
> > [ 60.799813][ T1] platform_device_add+0x274/0x628
> > [ 60.804833][ T1] acpi_iort_init+0x9d8/0xc50
> > [ 60.809415][ T1] acpi_init+0x45c/0x4e8
> > [ 60.813556][ T1] do_one_initcall+0x170/0xb70
> > [ 60.818224][ T1] kernel_init_freeable+0x6a8/0x734
> > [ 60.823332][ T1] kernel_init+0x18/0x12c
> > [ 60.827566][ T1] ret_from_fork+0x10/0x1c
> > [ 60.838756][ T1] ---[ end trace fa5c8ce17a226d83 ]---
> >
> > [1] - https://lore.kernel.org/linux-arm-kernel/[email protected]/
> > Fixes: 01bb86b380a3 ("driver core: Add fwnode_init()")
> > Reported-by: Qian Cai <[email protected]>
> > Suggested-by: Robin Murphy <[email protected]>
> > Tested-by: Marc Zyngier <[email protected]>
> > Signed-off-by: Saravana Kannan <[email protected]>
>
> Acked-by: Rafael J. Wysocki <[email protected]>

Now queued up, thanks.

greg k-h