HE> void inst_list_free(struct inst_list *list)
HE> {
HE> + if (!list)
HE> + return;
HE> +
HE> free(list->list);
HE> inst_list_init(list);
HE> }
I have no problem with this patch, although I'd like to reiterate that
it won't solve the initialization problem.
If you have this:
struct inst_list foo;
inst_list_free(&foo);
You're passing in the address of a stack variable, which will never be
NULL, so the additional check will fall through. The free() will then
attempt to free a garbage pointer (list is valid, but list->list is
not) and the heap is blown.
I'd also point out that we overwhelmingly use inst_list variables on
the stack, which means 99% of the time, this check won't help us, and
will just consume "extra cycles". I'm sure that this would eclipse
the overhead of a few unnecessary inst_list_init() calls :)
I'm fine applying this to handle the case where we might have a
dynamically-allocated list pointer. Any objections?
--
Dan Smith
IBM Linux Technology Center
Open Hypervisor Team
email: danms(a)us.ibm.com