Bug 203499 - KASSERT for non-NULL in g_uzip.c after value is dereferenced
Summary: KASSERT for non-NULL in g_uzip.c after value is dereferenced
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs mailing list
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2015-10-02 03:20 UTC by chadf
Modified: 2015-10-02 04:00 UTC (History)
0 users

See Also:


Attachments
Patch to correct error (619 bytes, patch)
2015-10-02 03:20 UTC, chadf
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description chadf 2015-10-02 03:20:33 UTC
Created attachment 161639 [details]
Patch to correct error

g_uzip_destroy_geom() in g_uzip.c deferences the variable 'gp' before the KASSERT(gp != NULL) is called. The assertion should be moved up.

        if (gp->softc == NULL) {
                DPRINTF(("%s(%s): gp->softc == NULL\n", __func__, gp->name));
                return (ENXIO);
        }

        KASSERT(gp != NULL, ("NULL geom"));

-->>

        KASSERT(gp != NULL, ("NULL geom"));
        if (gp->softc == NULL) {
                DPRINTF(("%s(%s): gp->softc == NULL\n", __func__, gp->name));
                return (ENXIO);
        }

Patch included.