ARM Sunxi Platform Development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arnd Bergmann" <arnd@kernel.org>
Cc: olteanv@gmail.com, linux-phy@lists.infradead.org,
	linux-sunxi@lists.linux.dev, vkoul@kernel.org,
	dmitry.torokhov@gmail.com, linux-input@vger.kernel.org,
	neil.armstrong@linaro.org
Subject: Re: [PATCH 08/13] pcmcia: replace linux/gpio.h inclusions
Date: Tue, 30 Jun 2026 13:28:32 +0000	[thread overview]
Message-ID: <20260630132833.450051F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260629132633.1300009-9-arnd@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Invalid resource cleanup on error path leading to potential double-free of a devres-managed GPIO descriptor.
--

commit a1a20647914d78d6a15655dea889e9d53c734136
Author: Arnd Bergmann <arnd@arndb.de>

pcmcia: replace linux/gpio.h inclusions

The pcmcia drivers all use the legacy interfaces, so convert to
include linux/gpio/legacy.h instead.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>

[ ... ]

> diff --git a/drivers/pcmcia/sa1100_h3600.c b/drivers/pcmcia/sa1100_h3600.c
> index 10cb99c20a7f5..6c52d90795eb4 100644
> --- a/drivers/pcmcia/sa1100_h3600.c
> +++ b/drivers/pcmcia/sa1100_h3600.c
> @@ -11,7 +11,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/init.h>
>  #include <linux/delay.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/legacy.h>

[Severity: High]
This isn't a bug introduced by this patch, but I noticed a pre-existing
issue while reviewing the GPIO include changes.

Does the error path in h3600_pcmcia_hw_init() cause a double-free of a
devres-managed GPIO descriptor?

If gpio_request(H3XXX_EGPIO_OPT_NVRAM_ON) or subsequent legacy GPIO requests
fail, the code jumps to or falls through to the err01 label:

drivers/pcmcia/sa1100_h3600.c:h3600_pcmcia_hw_init() {
    ...
err06:  gpio_free(H3XXX_EGPIO_CARD_RESET);
err05:  gpio_free(H3XXX_EGPIO_OPT_RESET);
err04:  gpio_free(H3XXX_EGPIO_OPT_ON);
err03:  gpio_free(H3XXX_EGPIO_OPT_NVRAM_ON);
err01:  gpio_free(H3XXX_GPIO_PCMCIA_IRQ0);
        return err;
}

The err01 label incorrectly frees H3XXX_GPIO_PCMCIA_IRQ0. This GPIO is
managed by devres and was not explicitly requested using gpio_request() in
this function. 

When devres cleans up the failed probe, it will attempt to free the GPIO
again. This could lead to a double-free, gpiolib state corruption, kernel
warnings, or accidentally freeing a GPIO acquired by a concurrent driver.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260629132633.1300009-1-arnd@kernel.org?part=8

  reply	other threads:[~2026-06-30 13:28 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-29 13:26 [PATCH 00/13] treewide: replace linux/gpio.h Arnd Bergmann
2026-06-29 13:26 ` [PATCH 01/13] ARM: replace linux/gpio.h inclusions Arnd Bergmann
2026-06-29 13:26 ` [PATCH 02/13] m68k/coldfire: " Arnd Bergmann
2026-06-29 13:26 ` [PATCH 03/13] mips: " Arnd Bergmann
2026-06-29 13:26 ` [PATCH 04/13] sh: " Arnd Bergmann
2026-06-29 13:26 ` [PATCH 05/13] mfd: " Arnd Bergmann
2026-06-30 13:28   ` sashiko-bot
2026-06-29 13:26 ` [PATCH 06/13] [net-next] net: " Arnd Bergmann
2026-06-30 13:28   ` sashiko-bot
2026-06-29 13:26 ` [PATCH 07/13] ASoC: " Arnd Bergmann
2026-06-30 13:28   ` sashiko-bot
2026-06-29 13:26 ` [PATCH 08/13] pcmcia: " Arnd Bergmann
2026-06-30 13:28   ` sashiko-bot [this message]
2026-06-30 13:36     ` Arnd Bergmann
2026-06-29 13:26 ` [PATCH 09/13] phy: " Arnd Bergmann
2026-06-30 13:28   ` sashiko-bot
2026-06-30 13:37     ` Arnd Bergmann
2026-06-29 13:26 ` [PATCH 10/13] media: " Arnd Bergmann
2026-06-29 13:26 ` [PATCH 11/13] Input: matrix_keyboard - replace linux/gpio.h inclusion Arnd Bergmann
2026-06-30 13:28   ` sashiko-bot
2026-06-29 13:26 ` [PATCH 12/13] gpib: gpio: " Arnd Bergmann
2026-06-30 13:28   ` sashiko-bot
2026-06-29 13:26 ` [PATCH 13/13] gpiolib: remove linux/gpio.h Arnd Bergmann
2026-06-30 13:28   ` sashiko-bot
2026-06-30 13:31     ` Arnd Bergmann
2026-06-29 14:01 ` [PATCH 00/13] treewide: replace linux/gpio.h Andreas Schwab
2026-06-29 14:24   ` Arnd Bergmann
2026-06-30  7:53 ` Bartosz Golaszewski

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=20260630132833.450051F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=arnd@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@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