Linux ACPI
 help / color / mirror / Atom feed
From: Ira Weiny <ira.weiny@intel.com>
To: Colin Ian King <colin.i.king@gmail.com>,
	"Rafael J . Wysocki" <rafael@kernel.org>,
	Len Brown <lenb@kernel.org>, James Morse <james.morse@arm.com>,
	Tony Luck <tony.luck@intel.com>, Borislav Petkov <bp@alien8.de>,
	Ira Weiny <ira.weiny@intel.com>, <linux-acpi@vger.kernel.org>
Cc: <kernel-janitors@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][next] ACPI: APEI: EINJ: Fix check and iounmap of uninitialized pointer p
Date: Wed, 25 Jun 2025 16:40:35 -0500	[thread overview]
Message-ID: <685c6cd3bf88b_2c35442946c@iweiny-mobl.notmuch> (raw)
In-Reply-To: <20250624202937.523013-1-colin.i.king@gmail.com>

Colin Ian King wrote:
> In the case where a request_mem_region call fails and pointer r is null
> the error exit path via label 'out' will check for a non-null pointer
> p and try to iounmap it. However, pointer p has not been assigned a
> value at this point, so it may potentially contain any garbage value.
> Fix this by ensuring pointer p is initialized to NULL.
> 
> Fixes: 1a35c88302a3 ("ACPI: APEI: EINJ: Fix kernel test sparse warnings")
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
>  drivers/acpi/apei/einj-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
> index 7930acd1d3f3..fc801587df8e 100644
> --- a/drivers/acpi/apei/einj-core.c
> +++ b/drivers/acpi/apei/einj-core.c
> @@ -401,7 +401,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
>  	u32 table_size;
>  	int rc = -EIO;
>  	struct acpi_generic_address *trigger_param_region = NULL;
> -	struct acpi_einj_trigger __iomem *p;
> +	struct acpi_einj_trigger __iomem *p = NULL;

Apparently my review of these was pretty weak...  :-/

That said; Why not skip a goto as well?

Ira

diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c
index d6d7e36e3647..fae01795e7f6 100644
--- a/drivers/acpi/apei/einj-core.c
+++ b/drivers/acpi/apei/einj-core.c
@@ -410,7 +410,7 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
                       (unsigned long long)trigger_paddr,
                       (unsigned long long)trigger_paddr +
                            sizeof(trigger_tab) - 1);
-               goto out;
+               return -EIO;
        }
        p = ioremap_cache(trigger_paddr, sizeof(*p));
        if (!p) {
@@ -502,7 +502,6 @@ static int __einj_error_trigger(u64 trigger_paddr, u32 type,
                           table_size - sizeof(trigger_tab));
 out_rel_header:
        release_mem_region(trigger_paddr, sizeof(trigger_tab));
-out:
        if (p)
                iounmap(p);
 

  parent reply	other threads:[~2025-06-25 21:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-24 20:29 [PATCH][next] ACPI: APEI: EINJ: Fix check and iounmap of uninitialized pointer p Colin Ian King
2025-06-24 21:31 ` Dan Carpenter
2025-06-25 11:50   ` Dan Carpenter
2025-06-25 21:40 ` Ira Weiny [this message]
2025-06-25 21:43   ` Colin King (gmail)
2025-06-26 14:29     ` Ira Weiny
2025-06-26 18:53     ` Rafael J. Wysocki

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=685c6cd3bf88b_2c35442946c@iweiny-mobl.notmuch \
    --to=ira.weiny@intel.com \
    --cc=bp@alien8.de \
    --cc=colin.i.king@gmail.com \
    --cc=james.morse@arm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=tony.luck@intel.com \
    /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