Skip to contentSkip to conversation

acpi: add checking for NULL early param

PATCH Applied [email protected] 3 participants 3 messages Aug 20, 2008 – Aug 21, 2008 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 acpi: add checking for NULL early param

From: Cyrill Gorcunov <[email protected]>

The early_param handling function could recieve NULL pointer as argument in case if user didn't enter parameter value. So we have to be ready for a such situation and do check for NULL pointer if needed.

---

 drivers/acpi/tables.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/acpi/tables.c renamed from drivers/acpi/tables.c~acpi-add-checking-for-null-early-param +2 -0
diff -puN drivers/acpi/tables.c~acpi-add-checking-for-null-early-param drivers/acpi/tables.c
@@ -300,6 +300,8 @@ int __init acpi_table_init(void)
 
 static int __init acpi_parse_apic_instance(char *str)
 {
+	if (!str)
+		return -EINVAL;
 
 	acpi_apic_instance = simple_strtoul(str, NULL, 0);
 

_

Applied
#1 lore raw
Quoted 9 lines · [email protected] writes:

From: Cyrill Gorcunov <[email protected]>

The early_param handling function could recieve NULL pointer as argument in case if user didn't enter parameter value. So we have to be ready for a such situation and do check for NULL pointer if needed.

Queued for 2.6.27. Thanks.

But I wonder if it wouldn't be generally safer for the caller to just pass an empty string instead of NULL in this case?

-Andi

#2 lore raw

[Andi Kleen - Thu, Aug 21, 2008 at 08:46:12AM +0200]

| [email protected] writes:
| 
| > From: Cyrill Gorcunov <[email protected]>
| >
| > The early_param handling function could recieve NULL pointer as argument
| > in case if user didn't enter parameter value.  So we have to be ready for
| > a such situation and do check for NULL pointer if needed.
| >
| > Signed-off-by: Cyrill Gorcunov <[email protected]>
| > Cc: Andi Kleen <[email protected]>
| > Signed-off-by: Andrew Morton <[email protected]>
| 
| Queued for 2.6.27. Thanks.
| 
| But I wonder if it wouldn't be generally safer for the caller to just pass
| an empty string instead of NULL in this case?
| 
| -Andi
| 

Actually this would require to patch kernel code not in one place. There was some discusion about this

	http://lkml.org/lkml/2008/8/12/229

- in short it could lead to hidden bug since not all users of early_param are ready for this and they have to be checked.

- Cyrill -