[Bug 238309] geom/geom_slice.c: potential NULL pointer dereference in g_slice_dumpconf()

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Tue Jun 4 00:38:25 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238309

--- Comment #3 from Conrad Meyer <cem at freebsd.org> ---
dumpconf() is an overloaded API.  It is called in multiple ways in geom_dump.c:

1. NULL indent, NULL cp, !NULL pp
2. !NULL indent, NULL cp, !NULL pp
3. !NULL indent, NULL cp, NULL pp

I.e., NULL indent => !NULL pp.  But !NULL indent implies nothing about pp.  The
logic in g_slice_dumpconf is correct, though confusing.

It would probably be more clear to assert these invariants, which might inform
PVS-Studio well enough to clear the false positives.  Something like:

    #define KASSERT_IMPLIES(a, b, c) KASSERT(!(a) || (b), c)

    ...

    KASSERT_IMPLIES(indent == NULL, pp != NULL, ("dumpconf API violation"));

tl;dr false positive

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list