Skip to contentSkip to conversation

ACPI/tables: Correct the wrong count increasing

PATCH Superseded Baoquan He 4 participants 11 messages Aug 8, 2016 – Aug 16, 2016

Subsystems (2)
lore
Share & tools
lore

Baoquan He

author
#0 lore raw

PATCH 1/2 ACPI/tables: Correct the wrong count increasing

The current code always increases the count in the 1st element of array proc[].

---
 drivers/acpi/tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/tables.c +1 -1
index 9f0ad6e..34d45bb 100644
@@ -281,7 +281,7 @@ acpi_parse_entries_array(char *id, unsigned long table_size,
 			     proc[i].handler(entry, table_end))
 				return -EINVAL;
 
-			proc->count++;
+			proc[i]->count++;
 			break;
 		}
 		if (i != proc_num)
Signature · 1 line
2.5.5
author
#1 lore raw

PATCH 2/2 x86, ACPI: Fix the wrong assignment when Handle apic/x2apic entries

It won't impact the result, we still should fix the code bug.

Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/kernel/acpi/boot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/acpi/boot.c +2 -2
index 90d84c3..2b25d3f 100644
@@ -1031,8 +1031,8 @@ static int __init acpi_parse_madt_lapic_entries(void)
 			return ret;
 		}
 
-		x2count = madt_proc[0].count;
-		count = madt_proc[1].count;
+		count = madt_proc[0].count;
+		x2count = madt_proc[1].count;
 	}
 	if (!count && !x2count) {
 		printk(KERN_ERR PREFIX "No LAPIC entries present\n");
Signature · 1 line
2.5.5
#6 lore raw
In reply to Baoquan He
reproduce:

Hi Baoquan,

[auto build test ERROR on pm/linux-next]
[also build test ERROR on v4.8-rc1 next-20160808]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Baoquan-He/ACPI-tables-Correct-the-wrong-count-increasing/20160809-070345
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: x86_64-randconfig-x002-201632 (attached as .config)
compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

drivers/acpi/tables.c: In function 'acpi_parse_entries_array':

>> drivers/acpi/tables.c:284:11: error: invalid type argument of '->' (have 'struct acpi_subtable_proc')
       proc[i]->count++;
              ^~

vim +284 drivers/acpi/tables.c

278 if (entry->type != proc[i].id)
279 continue;
280 if (!proc[i].handler ||
281 proc[i].handler(entry, table_end))
282 return -EINVAL;
283

 > 284				proc[i]->count++;

285 break;
286 }
287 if (i != proc_num)

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

author
#7 lore raw

Sorry, I tested in another system, but forget updating code on my laptop.

Will reply with a v2 post.

Sorry again about this mistake.

author
#8 lore raw

PATCH v2 1/2 ACPI/tables: Correct the wrong count increasing

In reply to Baoquan He

The current code always increases the count in the 1st element of array proc[].

---

v1->v2:
V1 is a wrong post because I didn't update the tested code to my local laptop. Repost with a correct v2.

 drivers/acpi/tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/tables.c +1 -1
index 9f0ad6e..34d45bb 100644
@@ -281,7 +281,7 @@ acpi_parse_entries_array(char *id, unsigned long table_size,
 			     proc[i].handler(entry, table_end))
 				return -EINVAL;
 
-			proc->count++;
+			proc[i].count++;
 			break;
 		}
 		if (i != proc_num)
Signature · 1 line
2.5.5
#2 lore raw

Re: [PATCH 2/2] x86, ACPI: Fix the wrong assignment when Handle apic/x2apic entries

In reply to Baoquan He
Quoted 20 lines · Baoquan He

It won't impact the result, we still should fix the code bug.

Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/kernel/acpi/boot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/acpi/boot.c +0 -0
index 90d84c3..2b25d3f 100644

arch/x86/kernel/acpi/boot.c static int __init acpi_parse_madt_lapic_entries(void) · line 1038

Quoted 10 lines
arch/x86/kernel/acpi/boot.c +2 -2
@@ -1031,8 +1031,8 @@ static int __init acpi_parse_madt_lapic_entries(void)
 			return ret;
 		}
 
-		x2count = madt_proc[0].count;
-		count = madt_proc[1].count;
+		count = madt_proc[0].count;
+		x2count = madt_proc[1].count;
 	}
 	if (!count && !x2count) {
 		printk(KERN_ERR PREFIX "No LAPIC entries present\n");

Why does this bug have no effect?

Thanks,

Ingo

author
#3 lore raw

Re: [PATCH 2/2] x86, ACPI: Fix the wrong assignment when Handle apic/x2apic entries

Quoted 26 lines · Ingo Molnar
Quoted 23 lines · Baoquan He

It won't impact the result, we still should fix the code bug.

Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/kernel/acpi/boot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/acpi/boot.c +0 -0
index 90d84c3..2b25d3f 100644
@@ -1031,8 +1031,8 @@ static int __init acpi_parse_madt_lapic_entries(void)
 			return ret;
 		}
 
Quoted 6 lines

arch/x86/kernel/acpi/boot.c static int __init acpi_parse_madt_lapic_entries(void) · line 1037

Quoted 6 lines
arch/x86/kernel/acpi/boot.c +2 -2
-		x2count = madt_proc[0].count;
-		count = madt_proc[1].count;
+		count = madt_proc[0].count;
+		x2count = madt_proc[1].count;
 	}
 	if (!count && !x2count) {
          ~~~~~~~~~~~~~~~~~~~~~

I mean here the value checking won't be impacted by the wrong assignment.

Quoted 7 lines

arch/x86/kernel/acpi/boot.c static int __init acpi_parse_madt_lapic_entries(void) · line 1038

Quoted 1 line
arch/x86/kernel/acpi/boot.c +0 -0
 		printk(KERN_ERR PREFIX "No LAPIC entries present\n");

Why does this bug have no effect?

Thanks,

Ingo

#4 lore raw

Re: [PATCH 2/2] x86, ACPI: Fix the wrong assignment when Handle apic/x2apic entries

Quoted 34 lines · Baoquan He
Quoted 26 lines · Ingo Molnar
Quoted 23 lines · Baoquan He

It won't impact the result, we still should fix the code bug.

Cc "Rafael J. Wysocki" <[email protected]>
Cc Len Brown <[email protected]>
Cc Pavel Machek <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc "H. Peter Anvin" <[email protected]>
---
 arch/x86/kernel/acpi/boot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/acpi/boot.c +0 -0
index 90d84c3..2b25d3f 100644
@@ -1031,8 +1031,8 @@ static int __init acpi_parse_madt_lapic_entries(void)
 			return ret;
 		}
 
Quoted 6 lines

arch/x86/kernel/acpi/boot.c static int __init acpi_parse_madt_lapic_entries(void) · line 1037

Quoted 6 lines
arch/x86/kernel/acpi/boot.c +2 -2
-		x2count = madt_proc[0].count;
-		count = madt_proc[1].count;
+		count = madt_proc[0].count;
+		x2count = madt_proc[1].count;
 	}
 	if (!count && !x2count) {
          ~~~~~~~~~~~~~~~~~~~~~
Quoted 2 lines

I mean here the value checking won't be impacted by the wrong assignment.

Indeed!

Mind putting that into the changelog? Something like:

"By pure accident the bug makes no functional difference, because the only
expression where we are using these values is (!count && !x2count), in which the variables are interchangeable, but it makes sense to fix the bug nevertheless."

Thanks,

Ingo

author
#5 lore raw

Re: [PATCH 2/2] x86, ACPI: Fix the wrong assignment when Handle apic/x2apic entries

Quoted 9 lines · Ingo Molnar
Quoted 8 lines
Quoted 5 lines

arch/x86/kernel/acpi/boot.c static int __init acpi_parse_madt_lapic_entries(void) · line 1037

Quoted 5 lines
arch/x86/kernel/acpi/boot.c +2 -1
-		count = madt_proc[1].count;
+		count = madt_proc[0].count;
+		x2count = madt_proc[1].count;
 	}
 	if (!count && !x2count) {
          ~~~~~~~~~~~~~~~~~~~~~

I mean here the value checking won't be impacted by the wrong assignment.

Quoted 8 lines

Indeed!

Mind putting that into the changelog? Something like:

"By pure accident the bug makes no functional difference, because the only
expression where we are using these values is (!count && !x2count), in which the variables are interchangeable, but it makes sense to fix the bug nevertheless."

Sure, this is much clearer. Will use this and repost. Thanks a lot, will try to do each post using patch log like this.

Thanks
Baoquan

#9 lore raw
In reply to Baoquan He

Hi,

Quoted 25 lines

From: [email protected] [mailto:[email protected]] On Behalf Of Baoquan He
Subject: [PATCH v2 1/2] ACPI/tables: Correct the wrong count increasing

The current code always increases the count in the 1st element of array proc[].

---

v1->v2:
V1 is a wrong post because I didn't update the tested code to my local laptop. Repost with a correct v2.

 drivers/acpi/tables.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/tables.c +0 -0
index 9f0ad6e..34d45bb 100644

drivers/acpi/tables.c acpi_parse_entries_array(char *id, unsigned long table_size, · line 284

Quoted 5 lines
drivers/acpi/tables.c +1 -1
@@ -281,7 +281,7 @@ acpi_parse_entries_array(char *id, unsigned long table_size,
 			     proc[i].handler(entry, table_end))
 				return -EINVAL;
 
-			proc->count++;
+			proc[i].count++;

Do we have code using acpi_subtable_proce.count?
I think the answer is yes because of:
[Patch] x86, ACPI: Fix the wrong assignment when Handle apic/x2apic entries

So why don't you put these 2 patches together into a single series? And help to validate if there are problems in other acpi_subtable_proce.count users.

Thanks
Lv

Quoted 10 lines
drivers/acpi/tables.c +0 -1
 			break;
 		}
 		if (i != proc_num)
--

2.5.5

--
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

author
#10 lore raw
Quoted 18 lines · Lv

Hi,

drivers/acpi/tables.c acpi_parse_entries_array(char *id, unsigned long table_size, · line 284

Quoted 11 lines

From: [email protected] [mailto:[email protected]] On Behalf Of Baoquan

drivers/acpi/tables.c +1 -1
index 9f0ad6e..34d45bb 100644
@@ -281,7 +281,7 @@ acpi_parse_entries_array(char *id, unsigned long table_size,
 			     proc[i].handler(entry, table_end))
 				return -EINVAL;
 
-			proc->count++;
+			proc[i].count++;

Do we have code using acpi_subtable_proce.count?
I think the answer is yes because of:
[Patch] x86, ACPI: Fix the wrong assignment when Handle apic/x2apic entries

Quoted 2 lines

So why don't you put these 2 patches together into a single series? And help to validate if there are problems in other acpi_subtable_proce.count users.

Thanks for comments. I hesitated to put them into one patch or two patches when I post. Later I decided to post them in two patches because they are in two components, one is x86, the other is ACPI. And though very simple fix I worry they can't be described well in one patch log.

Anyway, change related to patch 1/2 had been included in Al Stone's patchset posted earlier. So this one has to be NACKed.

Quoted 14 lines

Thanks
Lv

Quoted 10 lines
drivers/acpi/tables.c +0 -1
 			break;
 		}
 		if (i != proc_num)
--

2.5.5

--
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