From: Myeonghun Pak <mhun512@gmail.com>
To: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Myeonghun Pak <mhun512@gmail.com>,
Ijae Kim <ae878000@gmail.com>
Subject: [PATCH] net: 8390: pcnet_cs: release PCMCIA window on setup_shmem_window() error
Date: Sat, 1 Aug 2026 01:17:40 +0900 [thread overview]
Message-ID: <20260731161740.44955-1-mhun512@gmail.com> (raw)
setup_shmem_window() acquires a PCMCIA memory window with
pcmcia_request_window() and only releases it on the buffer-verification
failure path. If pcmcia_map_mem_page() or the subsequent ioremap()
fails, the function jumps straight to the "failed" label, which returns
without calling pcmcia_release_window(). The requested window is leaked.
This is reachable in practice: pcnet_config() treats a
setup_shmem_window() failure as non-fatal and falls back to
setup_dma_config(), so probe can continue and even succeed while the
requested shared-memory window is left allocated.
Route the post-request error paths through a new "release" label that
calls pcmcia_release_window() before returning, and fold the existing
buffer-verification cleanup into it. iounmap() is still performed before
the release where an ioremap() mapping exists, preserving the original
teardown order. The pcmcia_request_window() failure path still returns
directly, as no window is held there.
This issue was identified during our ongoing static-analysis research while
reviewing kernel code.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
drivers/net/ethernet/8390/pcnet_cs.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/8390/pcnet_cs.c b/drivers/net/ethernet/8390/pcnet_cs.c
index 19f9c5db3f3b..e2081d493749 100644
--- a/drivers/net/ethernet/8390/pcnet_cs.c
+++ b/drivers/net/ethernet/8390/pcnet_cs.c
@@ -1434,14 +1434,14 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
offset -= offset % window_size;
ret = pcmcia_map_mem_page(link, link->resource[3], offset);
if (ret)
- goto failed;
+ goto release;
/* Try scribbling on the buffer */
info->base = ioremap(link->resource[3]->start,
resource_size(link->resource[3]));
if (unlikely(!info->base)) {
ret = -ENOMEM;
- goto failed;
+ goto release;
}
for (i = 0; i < (TX_PAGES<<8); i += 2)
@@ -1452,9 +1452,8 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
pcnet_reset_8390(dev);
if (i != (TX_PAGES<<8)) {
iounmap(info->base);
- pcmcia_release_window(link, link->resource[3]);
info->base = NULL;
- goto failed;
+ goto release;
}
ei_status.mem = info->base + offset;
@@ -1475,6 +1474,8 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
info->flags |= USE_SHMEM;
return 0;
+release:
+ pcmcia_release_window(link, link->resource[3]);
failed:
return 1;
}
--
2.47.1
reply other threads:[~2026-07-31 16:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260731161740.44955-1-mhun512@gmail.com \
--to=mhun512@gmail.com \
--cc=ae878000@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@dominikbrodowski.net \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--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