From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Asmaa Mnebhi <asmaa@nvidia.com>,
linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH 06/10] gpio: mlxbf2: Embed context save registers to prevent suspend NULL dereference
Date: Thu, 3 Dec 2026 20:55:04 +0000 [thread overview]
Message-ID: <20261203205606.3905705-7-lee@kernel.org> (raw)
In-Reply-To: <20261203205606.3905705-1-lee@kernel.org>
struct mlxbf2_gpio_context declares csave_regs as a pointer that is
never allocated during probe. Both mlxbf2_gpio_suspend() and
mlxbf2_gpio_resume() unconditionally dereference gs->csave_regs,
causing a NULL pointer dereference on system suspend.
Embed struct mlxbf2_gpio_context_save_regs directly inside struct
mlxbf2_gpio_context.
Fixes: bc0ae0e737f5 ("gpio: add driver for Mellanox BlueField 2 GPIO controller")
Closes: https://sashiko.dev/#/bug/linux-a27fa304-ac63-43b1-94b8-0b30e7a2e1bc
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/gpio/gpio-mlxbf2.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/gpio/gpio-mlxbf2.c b/drivers/gpio/gpio-mlxbf2.c
index ed724d544c03..534ad29be19e 100644
--- a/drivers/gpio/gpio-mlxbf2.c
+++ b/drivers/gpio/gpio-mlxbf2.c
@@ -72,7 +72,7 @@ struct mlxbf2_gpio_context {
void __iomem *gpio_io;
struct device *dev;
- struct mlxbf2_gpio_context_save_regs *csave_regs;
+ struct mlxbf2_gpio_context_save_regs csave_regs;
};
/* BlueField-2 gpio shared structure. */
@@ -440,10 +440,8 @@ static int mlxbf2_gpio_suspend(struct device *dev)
{
struct mlxbf2_gpio_context *gs = dev_get_drvdata(dev);
- gs->csave_regs->gpio_mode0 = readl(gs->gpio_io +
- YU_GPIO_MODE0);
- gs->csave_regs->gpio_mode1 = readl(gs->gpio_io +
- YU_GPIO_MODE1);
+ gs->csave_regs.gpio_mode0 = readl(gs->gpio_io + YU_GPIO_MODE0);
+ gs->csave_regs.gpio_mode1 = readl(gs->gpio_io + YU_GPIO_MODE1);
return 0;
}
@@ -452,10 +450,8 @@ static int mlxbf2_gpio_resume(struct device *dev)
{
struct mlxbf2_gpio_context *gs = dev_get_drvdata(dev);
- writel(gs->csave_regs->gpio_mode0, gs->gpio_io +
- YU_GPIO_MODE0);
- writel(gs->csave_regs->gpio_mode1, gs->gpio_io +
- YU_GPIO_MODE1);
+ writel(gs->csave_regs.gpio_mode0, gs->gpio_io + YU_GPIO_MODE0);
+ writel(gs->csave_regs.gpio_mode1, gs->gpio_io + YU_GPIO_MODE1);
return 0;
}
--
2.56.1.911.g883d8bcb20-goog
next prev parent reply other threads:[~2026-12-03 20:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 20:54 [PATCH 00/10] gpio: Fix Critical and High issues reported by Sashiko Lee Jones
2026-12-03 20:54 ` [PATCH 01/10] gpio: davinci: Validate ngpio against MAX_REGS_BANKS in davinci_gpio_probe() Lee Jones
2026-12-03 20:55 ` [PATCH 02/10] gpiolib: acpi: Hold gpio_device reference in acpi_dev_gpio_irq_wake_get_by() Lee Jones
2026-12-03 20:55 ` [PATCH 03/10] gpio: mvebu: Clear chained IRQ handlers on unbind Lee Jones
2026-12-03 21:13 ` sashiko-bot
2026-12-03 20:55 ` [PATCH 04/10] gpio: rockchip: Unregister gpiochip on pin-range lookup errors Lee Jones
2026-12-03 20:55 ` [PATCH 05/10] gpiolib: Avoid undersized array bitmap in set fastpath Lee Jones
2026-12-03 20:55 ` Lee Jones [this message]
2026-12-03 20:55 ` [PATCH 07/10] gpio: regmap: Use resolved chip->ngpio for default ngpio_per_reg Lee Jones
2026-12-03 20:55 ` [PATCH 08/10] gpio: mpc8xxx: Drop stale remove callback clearing chained handler Lee Jones
2026-12-03 21:17 ` sashiko-bot
2026-12-03 20:55 ` [PATCH 09/10] gpio: mpsse: Allocate DMA-safe buffer in mpsse_write() Lee Jones
2026-12-03 20:55 ` [PATCH 10/10] gpio: pcie-idio-24: Fix COS_ENABLE_RISING bit definition Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261203205606.3905705-7-lee@kernel.org \
--to=lee@kernel.org \
--cc=asmaa@nvidia.com \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox