]> git.baikalelectronics.ru Git - kernel.git/commit
gpio: tegra186: Fix chip_data type confusion
authorMarc Zyngier <maz@kernel.org>
Fri, 11 Feb 2022 09:39:04 +0000 (09:39 +0000)
committerLinus Walleij <linus.walleij@linaro.org>
Sat, 19 Feb 2022 00:51:24 +0000 (01:51 +0100)
commit72f8d9ffe9b7ac6b098a6fadae74f905b8411c45
tree6bba3806a20795b111bd89ee4481a75301af0ece
parent7859a5be0194981f85b7d470385b106fa0ecc484
gpio: tegra186: Fix chip_data type confusion

The tegra186 GPIO driver makes the assumption that the pointer
returned by irq_data_get_irq_chip_data() is a pointer to a
tegra_gpio structure. Unfortunately, it is actually a pointer
to the inner gpio_chip structure, as mandated by the gpiolib
infrastructure. Nice try.

The saving grace is that the gpio_chip is the first member of
tegra_gpio, so the bug has gone undetected since... forever.

Fix it by performing a container_of() on the pointer. This results
in no additional code, and makes it possible to understand how
the whole thing works.

Fixes: 34b2ebfb7da9 ("gpio: Add Tegra186 support")
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: Thierry Reding <treding@nvidia.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Link: https://lore.kernel.org/r/20220211093904.1112679-1-maz@kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-tegra186.c