Summary: | KASSERT for non-NULL in g_uzip.c after value is dereferenced | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | chadf | ||||
Component: | kern | Assignee: | Andriy Voskoboinyk <avos> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Some People | CC: | avos, cem | ||||
Priority: | --- | Keywords: | patch | ||||
Version: | CURRENT | Flags: | avos:
mfc-stable12+
avos: mfc-stable11+ avos: mfc-stable10+ |
||||
Hardware: | Any | ||||||
OS: | Any | ||||||
Attachments: |
|
A commit references this bug: Author: avos Date: Sat Jan 26 14:54:07 UTC 2019 New revision: 343473 URL: https://svnweb.freebsd.org/changeset/base/343473 Log: geom_uzip(4): move NULL pointer KASSERT check before it is dereferenced PR: 203499 Submitted by: <chadf@triularity.org> MFC after: 5 days Changes: head/sys/geom/uzip/g_uzip.c @avos, See also: @@ -889,13 +889,13 @@ g_uzip_destroy_geom(struct gctl_req *req, struct g_cla g_trace(G_T_TOPOLOGY, "%s(%s, %s)", __func__, mp->name, gp->name); ^^^^^^^^ g_topology_assert(); + KASSERT(gp != NULL, ("NULL geom")); if (gp->softc == NULL) { A commit references this bug: Author: avos Date: Sat Jan 26 17:17:25 UTC 2019 New revision: 343475 URL: https://svnweb.freebsd.org/changeset/base/343475 Log: geom_uzip(4): set 'gp != NULL' assertion on top of the function There was yet another access to this variable in g_trace() few lines upper. PR: 203499 Reported by: cem MFC after: 5 days MFC with: 343473 Changes: head/sys/geom/uzip/g_uzip.c A commit references this bug: Author: avos Date: Thu Jan 31 11:36:29 UTC 2019 New revision: 343605 URL: https://svnweb.freebsd.org/changeset/base/343605 Log: MFC r343473: geom_uzip(4): move NULL pointer KASSERT check before it is dereferenced PR: 203499 Submitted by: <chadf@triularity.org> MFC r343475: geom_uzip(4): set 'gp != NULL' assertion on top of the function There was yet another access to this variable in g_trace() few lines upper. PR: 203499 Reported by: cem Changes: _U stable/10/ stable/10/sys/geom/uzip/g_uzip.c _U stable/11/ stable/11/sys/geom/uzip/g_uzip.c _U stable/12/ stable/12/sys/geom/uzip/g_uzip.c A commit references this bug: Author: avos Date: Thu Jan 31 11:36:29 UTC 2019 New revision: 343605 URL: https://svnweb.freebsd.org/changeset/base/343605 Log: MFC r343473: geom_uzip(4): move NULL pointer KASSERT check before it is dereferenced PR: 203499 Submitted by: <chadf@triularity.org> MFC r343475: geom_uzip(4): set 'gp != NULL' assertion on top of the function There was yet another access to this variable in g_trace() few lines upper. PR: 203499 Reported by: cem Changes: _U stable/10/ stable/10/sys/geom/uzip/g_uzip.c _U stable/11/ stable/11/sys/geom/uzip/g_uzip.c _U stable/12/ stable/12/sys/geom/uzip/g_uzip.c |
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.