Skip to contentSkip to conversation

ACPI, extlog: remove unneeded NULL check

PATCH In review Dan Carpenter 4 participants 7 messages Nov 5, 2013 – Nov 11, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 ACPI, extlog: remove unneeded NULL check

We dereference extlog_l1_addr so the check is too late. The "extlog_l1_addr" pointer can never be NULL when this function is called so I have removed the check.

drivers/acpi/acpi_extlog.c +1 -2
index c4d5e59..d59e4bb 100644
@@ -308,8 +308,7 @@ static void __exit extlog_exit(void)
 {
 	mce_unregister_decode_chain(&extlog_mce_dec);
 	((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
-	if (extlog_l1_addr)
-		acpi_os_unmap_memory(extlog_l1_addr, l1_size);
+	acpi_os_unmap_memory(extlog_l1_addr, l1_size);
 	if (elog_addr)
 		acpi_os_unmap_memory(elog_addr, elog_size);
 	release_mem_region(elog_base, elog_size);
#1 lore raw
Quoted 5 lines · Dan Carpenter

We dereference extlog_l1_addr so the check is too late. The "extlog_l1_addr" pointer can never be NULL when this function is called so I have removed the check.

I'm wondering what kernel you have checked, because drivers/acpi/acpi_extlog.c is not present in the mainline or even in linux-next?

Rafael

Quoted 19 lines
drivers/acpi/acpi_extlog.c +1 -3
index c4d5e59..d59e4bb 100644
@@ -308,8 +308,7 @@ static void __exit extlog_exit(void)
 {
 	mce_unregister_decode_chain(&extlog_mce_dec);
 	((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
-	if (extlog_l1_addr)
-		acpi_os_unmap_memory(extlog_l1_addr, l1_size);
+	acpi_os_unmap_memory(extlog_l1_addr, l1_size);
 	if (elog_addr)
 		acpi_os_unmap_memory(elog_addr, elog_size);
 	release_mem_region(elog_base, elog_size);
--

To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
#2 lore raw
Quoted 2 lines · Rafael J. Wysocki

I'm wondering what kernel you have checked, because drivers/acpi/acpi_extlog.c is not present in the mainline or even in linux-next?

It's in the "tip" tree ... and seems to be in next-20131106

-Tony

#3 lore raw
Quoted 5 lines · Tony Luck
Quoted 2 lines · Rafael J. Wysocki

I'm wondering what kernel you have checked, because drivers/acpi/acpi_extlog.c is not present in the mainline or even in linux-next?

It's in the "tip" tree ... and seems to be in next-20131106

Well, OK. Who's going to maintain this file?

Rafael

#4 lore raw
Quoted 11 lines · Rafael J. Wysocki

Date: Thu, 07 Nov 2013 01:09:38 +0100
From: "Rafael J. Wysocki" <[email protected]>
To: Tony Luck <[email protected]>
Cc: Dan Carpenter <[email protected]>, Len Brown <[email protected]>,
Gong <[email protected]>, linux-acpi <[email protected]>, [email protected]
Subject: Re: [patch 2/2] ACPI, extlog: remove unneeded NULL check
User-Agent: KMail/4.10.5 (Linux/3.12.0-rc6+; KDE/4.10.5; x86_64; ; )

Quoted 1 line · Tony Luck

On Wed, Nov 6, 2013 at 2:06 PM, Rafael J. Wysocki <[email protected]> wrote:

Quoted 9 lines
Quoted 4 lines
Quoted 2 lines

I'm wondering what kernel you have checked, because drivers/acpi/acpi_extlog.c is not present in the mainline or even in linux-next?

It's in the "tip" tree ... and seems to be in next-20131106

Well, OK. Who's going to maintain this file?

Rafael

It's me. I will maintain this file.

BTW, Dan

According to your codes, I think elog_addr check can be removed, too. Can you send out a updated version?

#5 lore raw

PATCH v2 2/2 ACPI, extlog: remove unneeded NULL check

We dereference extlog_l1_addr before checking if is NULL. It turns out "extlog_l1_addr" pointer can never be NULL when this function is called so I have removed the check.

We can remove the "elog_addr" check as well.

---
v2: remove the elog_addr check as well.

drivers/acpi/acpi_extlog.c +2 -4
index a6869e1..17da458 100644
@@ -310,10 +310,8 @@ static void __exit extlog_exit(void)
 {
 	mce_unregister_decode_chain(&extlog_mce_dec);
 	((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
-	if (extlog_l1_addr)
-		acpi_os_unmap_memory(extlog_l1_addr, l1_size);
-	if (elog_addr)
-		acpi_os_unmap_memory(elog_addr, elog_size);
+	acpi_os_unmap_memory(extlog_l1_addr, l1_size);
+	acpi_os_unmap_memory(elog_addr, elog_size);
 	release_mem_region(elog_base, elog_size);
 	release_mem_region(l1_dirbase, l1_size);
 	kfree(elog_buf);
#6 lore raw
Quoted 25 lines · Dan Carpenter

Date: Fri, 8 Nov 2013 00:24:49 -0800 (PST)
From: Dan Carpenter <[email protected]>
To: Len Brown <[email protected]>, "Chen, Gong" <[email protected]>
Cc: "Rafael J. Wysocki" <[email protected]>, [email protected],
Tony Luck <[email protected]>, [email protected]
Subject: [patch 2/2 v2] ACPI, extlog: remove unneeded NULL check
USER-AGENT: Mutt/1.5.21 (2010-09-15)

We dereference extlog_l1_addr before checking if is NULL. It turns out "extlog_l1_addr" pointer can never be NULL when this function is called so I have removed the check.

We can remove the "elog_addr" check as well.

---
v2: remove the elog_addr check as well.

drivers/acpi/acpi_extlog.c +0 -0
index a6869e1..17da458 100644
@@ -310,10 +310,8 @@ static void __exit extlog_exit(void)
 {
 	mce_unregister_decode_chain(&extlog_mce_dec);

drivers/acpi/acpi_extlog.c static void __exit extlog_exit(void) · line 317

Quoted 10 lines
drivers/acpi/acpi_extlog.c +2 -4
 	((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
-	if (extlog_l1_addr)
-		acpi_os_unmap_memory(extlog_l1_addr, l1_size);
-	if (elog_addr)
-		acpi_os_unmap_memory(elog_addr, elog_size);
+	acpi_os_unmap_memory(extlog_l1_addr, l1_size);
+	acpi_os_unmap_memory(elog_addr, elog_size);
 	release_mem_region(elog_base, elog_size);
 	release_mem_region(l1_dirbase, l1_size);
 	kfree(elog_buf);