[LU-11887] OBD_FREE macro issues with OBD_DEBUG_MEMUSAGE and CONFIG_DEBUG_SLAB Created: 25/Jan/19  Updated: 04/Sep/19

Status: Open
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Patrick Farrell (Inactive) Assignee: WC Triage
Resolution: Unresolved Votes: 0
Labels: None

Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

There's some weirdness with the OBD_FREE family of macros, and at least one bug.

First item is more of a style thing, but:
free(), vfree(), and kfree() all accept null pointers without complaint.  This simplifies code in exit paths in many places.

The OBD_FREE macros do in their default version, and this behavior is used (inconsistently), but if OBD_DEBUG_MEMUSAGE is on, they do not, because OBD_FREE_PRE asserts the pointer is not null.

We should fix that in OBD_DEBUG_MEMUSAGE;

Then, next:

There are several bugs with POISON_PTR.

If OBD_DEBUG_MEMUSAGE is on:
OBD_FREE poisons the PTR twice.

if CONFIG_DEBUG_SLAB is on, POISON_PTR is enabled...

And we call it after freeing the pointer in several places:
#define OBD_FREE(ptr, size) \
do { \
OBD_FREE_PRE(ptr, size, "kfreed"); \
kfree(ptr); \
POISON_PTR(ptr); \
} while (0)

#define OBD_FREE_LARGE(ptr, size) \
do { \
if (is_vmalloc_addr(ptr))

{ \ OBD_FREE_PRE(ptr, size, "vfreed"); \ vfree(ptr); \ POISON_PTR(ptr); \ }

else {

 

Yuck!  I'll see about doing patches for this at some point.


Generated at Sat Feb 10 02:47:48 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.