Skip to contentSkip to conversation

ACPICA: fix possible NULL dereference

PATCH Zheng 1 participant 2 messages Sep 21, 2015 – Sep 23, 2015 1 message not in the archive ACPI component architecture (acpica)

lore
Share & tools
lore

Zheng

#1 lore raw
In reply to a message not in the archive

If it is intentional, can we put something like assert(), BUG_ON() there so that the checker can always be coded but not compiled when the binary is released?

Thanks
-Lv

Quoted 19 lines

From: Sudip Mukherjee [mailto:sudipm.mukherjee(a)gmail.com]
Sent: Friday, September 18, 2015 2:06 PM

Quoted 1 line · Robert

One of the things we always have to think about and look at is that often, things like this are *guaranteed" to be valid simply by

virtue of the fact that the code has gotten as far as it has.

Quoted 4 lines

So, rather than litter the code with NULL checks for every single access, we know up front that the object is valid.

This isn't always true and there are some valid situations, but we would appreciate it if you help track this down.

I tried but looks like acpi is very tough to understand. The only argument I can give in favor of my patch is that in all the places this function acpi_ns_get_secondary_object() has been used the return has been checked, only the three calls in this file acpi/acpica/dsargs.c has not checked the return. Like you said it might be intentional also to not check the return only in this file.

regards
sudip

#2 lore raw

This is the type of thing such that if we get to the code, it is guaranteed that NULL will not be returned by virtue of the fact that it would have been caught much earlier.

I don't want to start littering the code with assert, etc.

It is not as if we have not thought about these things and made certain decisions.

Bob

Quoted 36 lines

-----Original Message-----
From: Zheng, Lv
Sent: Sunday, September 20, 2015 5:59 PM
To: Sudip Mukherjee; Moore, Robert
Cc: Wysocki, Rafael J; Len Brown; devel(a)acpica.org
Subject: RE: [PATCH] ACPICA: fix possible NULL dereference

If it is intentional, can we put something like assert(), BUG_ON() there so that the checker can always be coded but not compiled when the binary is released?

Thanks
-Lv

Quoted 9 lines

From: Sudip Mukherjee [mailto:sudipm.mukherjee(a)gmail.com]
Sent: Friday, September 18, 2015 2:06 PM

Quoted 2 lines · Robert

One of the things we always have to think about and look at is that often, things like this are *guaranteed" to be valid simply by

virtue of the fact that the code has gotten as far as it has.

Quoted 2 lines

So, rather than litter the code with NULL checks for every single

access, we know up front that the object is valid.

Quoted 2 lines
Quoted 2 lines

This isn't always true and there are some valid situations, but we

would appreciate it if you help track this down.

Quoted 9 lines

I tried but looks like acpi is very tough to understand. The only argument I can give in favor of my patch is that in all the places this function acpi_ns_get_secondary_object() has been used the return has been checked, only the three calls in this file acpi/acpica/dsargs.c has not checked the return. Like you said it might be intentional also to not check the return only in this file.

regards
sudip