Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1281698 > unrolled thread

[PATCH] ACPI / extlog: don't dereference extlog_l1_addr if it is null

Started byColin King <colin.king@canonical.com>
First post2015-12-02 13:00 +0100
Last post2015-12-02 13:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ACPI / extlog: don't dereference extlog_l1_addr if it is null Colin King <colin.king@canonical.com> - 2015-12-02 13:00 +0100
    Re: [PATCH] ACPI / extlog: don't dereference extlog_l1_addr if it is  null Borislav Petkov <bp@alien8.de> - 2015-12-02 13:20 +0100

#1281698 — [PATCH] ACPI / extlog: don't dereference extlog_l1_addr if it is null

FromColin King <colin.king@canonical.com>
Date2015-12-02 13:00 +0100
Subject[PATCH] ACPI / extlog: don't dereference extlog_l1_addr if it is null
Message-ID<qBeeJ-6GK-1@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

There is a check to see if extlog_l1_addr is null before calling
acpi_os_unmap_iomem, however, before that call there is a
dereference on this that could trip an oops.  Move the
extlog_l1_addr dereference so it occurs only if it is not null.

Found by static analysis by smatch.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/acpi/acpi_extlog.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
index b3842ff..183b7b2 100644
--- a/drivers/acpi/acpi_extlog.c
+++ b/drivers/acpi/acpi_extlog.c
@@ -309,9 +309,10 @@ static void __exit extlog_exit(void)
 {
 	set_edac_report_status(old_edac_report_status);
 	mce_unregister_decode_chain(&extlog_mce_dec);
-	((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
-	if (extlog_l1_addr)
+	if (extlog_l1_addr) {
+		((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
 		acpi_os_unmap_iomem(extlog_l1_addr, l1_size);
+	}
 	if (elog_addr)
 		acpi_os_unmap_iomem(elog_addr, elog_size);
 	release_mem_region(elog_base, elog_size);
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1281713 — Re: [PATCH] ACPI / extlog: don't dereference extlog_l1_addr if it is null

FromBorislav Petkov <bp@alien8.de>
Date2015-12-02 13:20 +0100
SubjectRe: [PATCH] ACPI / extlog: don't dereference extlog_l1_addr if it is null
Message-ID<qBey8-72N-57@gated-at.bofh.it>
In reply to#1281698
CCing authors too.

On Wed, Dec 02, 2015 at 11:58:28AM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> There is a check to see if extlog_l1_addr is null before calling
> acpi_os_unmap_iomem, however, before that call there is a
> dereference on this that could trip an oops.  Move the
> extlog_l1_addr dereference so it occurs only if it is not null.
> 
> Found by static analysis by smatch.
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/acpi/acpi_extlog.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c
> index b3842ff..183b7b2 100644
> --- a/drivers/acpi/acpi_extlog.c
> +++ b/drivers/acpi/acpi_extlog.c
> @@ -309,9 +309,10 @@ static void __exit extlog_exit(void)
>  {
>  	set_edac_report_status(old_edac_report_status);
>  	mce_unregister_decode_chain(&extlog_mce_dec);
> -	((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
> -	if (extlog_l1_addr)
> +	if (extlog_l1_addr) {
> +		((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
>  		acpi_os_unmap_iomem(extlog_l1_addr, l1_size);
> +	}
>  	if (elog_addr)
>  		acpi_os_unmap_iomem(elog_addr, elog_size);
>  	release_mem_region(elog_base, elog_size);
> -- 
> 2.6.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web