2022-11-21 16:31:26

by Thomas Gleixner

[permalink] [raw]
Subject: [patch V2 01/40] irqchip/irq-mvebu-icu: Fix works by chance pointer assignment

Assigning a void pointer which points to a struct to two different data
types only works by chance if the second type is the first member of the
struct.

Replace this works by chance code by using the primary struct pointer.

Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Gregory Clement <[email protected]>
Cc: Sebastian Hesselbarth <[email protected]>
---
drivers/irqchip/irq-mvebu-icu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/irqchip/irq-mvebu-icu.c
+++ b/drivers/irqchip/irq-mvebu-icu.c
@@ -151,9 +151,9 @@ static int
mvebu_icu_irq_domain_translate(struct irq_domain *d, struct irq_fwspec *fwspec,
unsigned long *hwirq, unsigned int *type)
{
- struct mvebu_icu_msi_data *msi_data = platform_msi_get_host_data(d);
- struct mvebu_icu *icu = platform_msi_get_host_data(d);
unsigned int param_count = static_branch_unlikely(&legacy_bindings) ? 3 : 2;
+ struct mvebu_icu_msi_data *msi_data = platform_msi_get_host_data(d);
+ struct mvebu_icu *icu = msi_data->icu;

/* Check the count of the parameters in dt */
if (WARN_ON(fwspec->param_count != param_count)) {



2022-11-24 12:55:02

by Marc Zyngier

[permalink] [raw]
Subject: Re: [patch V2 01/40] irqchip/irq-mvebu-icu: Fix works by chance pointer assignment

On Mon, 21 Nov 2022 14:39:29 +0000,
Thomas Gleixner <[email protected]> wrote:
>
> Assigning a void pointer which points to a struct to two different data
> types only works by chance if the second type is the first member of the
> struct.
>
> Replace this works by chance code by using the primary struct pointer.
>
> Signed-off-by: Thomas Gleixner <[email protected]>
> Cc: Andrew Lunn <[email protected]>
> Cc: Gregory Clement <[email protected]>
> Cc: Sebastian Hesselbarth <[email protected]>

Acked-by: Marc Zyngier <[email protected]>

M.

--
Without deviation from the norm, progress is not possible.

Subject: [tip: irq/core] irqchip/irq-mvebu-icu: Fix works by chance pointer assignment

The following commit has been merged into the irq/core branch of tip:

Commit-ID: 55721afa8d8b82e442cb4eaf7173330f79cbfb48
Gitweb: https://git.kernel.org/tip/55721afa8d8b82e442cb4eaf7173330f79cbfb48
Author: Thomas Gleixner <[email protected]>
AuthorDate: Mon, 21 Nov 2022 15:39:29 +01:00
Committer: Thomas Gleixner <[email protected]>
CommitterDate: Tue, 06 Dec 2022 12:50:17 +01:00

irqchip/irq-mvebu-icu: Fix works by chance pointer assignment

Assigning a void pointer which points to a struct to two different data
types only works by chance if the second type is the first member of the
struct.

Replace this works by chance code by using the primary struct pointer.

Signed-off-by: Thomas Gleixner <[email protected]>
Acked-by: Marc Zyngier <[email protected]>
Link: https://lore.kernel.org/r/[email protected]

---
drivers/irqchip/irq-mvebu-icu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-mvebu-icu.c b/drivers/irqchip/irq-mvebu-icu.c
index 497da34..3c77acc 100644
--- a/drivers/irqchip/irq-mvebu-icu.c
+++ b/drivers/irqchip/irq-mvebu-icu.c
@@ -151,9 +151,9 @@ static int
mvebu_icu_irq_domain_translate(struct irq_domain *d, struct irq_fwspec *fwspec,
unsigned long *hwirq, unsigned int *type)
{
- struct mvebu_icu_msi_data *msi_data = platform_msi_get_host_data(d);
- struct mvebu_icu *icu = platform_msi_get_host_data(d);
unsigned int param_count = static_branch_unlikely(&legacy_bindings) ? 3 : 2;
+ struct mvebu_icu_msi_data *msi_data = platform_msi_get_host_data(d);
+ struct mvebu_icu *icu = msi_data->icu;

/* Check the count of the parameters in dt */
if (WARN_ON(fwspec->param_count != param_count)) {