From: Dominik Brodowski <linux@dominikbrodowski.net>
To: Ma Ke <make24@iscas.ac.cn>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
stable@vger.kernel.org
Subject: Re: [PATCH RESEND] pcmcia: Fix a NULL pointer dereference in __iodyn_find_io_region()
Date: Sat, 16 Aug 2025 16:42:15 +0200 [thread overview]
Message-ID: <aKCYx6-E-daskCzh@shine.dominikbrodowski.net> (raw)
In-Reply-To: <20250812072509.472061-1-make24@iscas.ac.cn>
Many thanks, applied to pcmcia-next. This allocation is practically no-fail
owing to GFP_KERNEL and the small allocation size, and rsrc_iodyn.c is on
its way out, but it's better safe than to be sorry.
Best,
Dominik
Am Tue, Aug 12, 2025 at 03:25:09PM +0800 schrieb Ma Ke:
> In __iodyn_find_io_region(), pcmcia_make_resource() is assigned to
> res and used in pci_bus_alloc_resource(). There is a dereference of res
> in pci_bus_alloc_resource(), which could lead to a NULL pointer
> dereference on failure of pcmcia_make_resource().
>
> Fix this bug by adding a check of res.
>
> Found by code review, complie tested only.
>
> Cc: stable@vger.kernel.org
> Fixes: 49b1153adfe1 ("pcmcia: move all pcmcia_resource_ops providers into one module")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> drivers/pcmcia/rsrc_iodyn.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/pcmcia/rsrc_iodyn.c b/drivers/pcmcia/rsrc_iodyn.c
> index b04b16496b0c..2677b577c1f8 100644
> --- a/drivers/pcmcia/rsrc_iodyn.c
> +++ b/drivers/pcmcia/rsrc_iodyn.c
> @@ -62,6 +62,9 @@ static struct resource *__iodyn_find_io_region(struct pcmcia_socket *s,
> unsigned long min = base;
> int ret;
>
> + if (!res)
> + return NULL;
> +
> data.mask = align - 1;
> data.offset = base & data.mask;
>
> --
> 2.25.1
>
>
prev parent reply other threads:[~2025-08-16 14:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 7:25 Ma Ke
2025-08-16 14:42 ` Dominik Brodowski [this message]
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=aKCYx6-E-daskCzh@shine.dominikbrodowski.net \
--to=linux@dominikbrodowski.net \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=make24@iscas.ac.cn \
--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
all inboxes | Powered by JetHome®