[V2,01/40] irqchip/irq-mvebu-icu: Fix works by chance pointer assignment

Message ID 20221121140048.344525618@linutronix.de
State New
Headers
Series genirq, irqchip: Convert ARM MSI handling to per device MSI domains |

Commit Message

Thomas Gleixner Nov. 21, 2022, 2:39 p.m. UTC
  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 <tglx@linutronix.de>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Gregory Clement <gregory.clement@bootlin.com>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
---
 drivers/irqchip/irq-mvebu-icu.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Marc Zyngier Nov. 24, 2022, 12:50 p.m. UTC | #1
On Mon, 21 Nov 2022 14:39:29 +0000,
Thomas Gleixner <tglx@linutronix.de> 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 <tglx@linutronix.de>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Gregory Clement <gregory.clement@bootlin.com>
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>

Acked-by: Marc Zyngier <maz@kernel.org>

	M.
  

Patch

--- 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)) {