Bug 207855

Summary: usr/src/sys/geom/vinum/geom_vinum_plex.c:173: bad assert ?
Product: Base System Reporter: David Binderman <dcb314>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me CC: emaste
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=207856

Description David Binderman 2016-03-09 19:30:42 UTC
usr/src/sys/geom/vinum/geom_vinum_plex.c:173]: (style) A pointer can not be negative so it is either pointless or an error to check if it is not.

Source code is

        KASSERT(sdno >= 0, ("gv_plex_offset: sdno < 0"));

but

gv_plex_offset(struct gv_plex *p, off_t boff, off_t bcount, off_t *real_off,
    off_t *real_len, int *sdno, int growing)
{
Comment 1 Ed Maste freebsd_committer freebsd_triage 2022-12-12 17:04:39 UTC
Presumably this was meant to be
KASSERT(*sdno >= 0, ("gv_plex_offset: sdno < 0"));
Comment 2 Ed Maste freebsd_committer freebsd_triage 2022-12-12 17:11:53 UTC
https://reviews.freebsd.org/D37677
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-03-21 14:03:41 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=87bb53cb538059a3085db1fa4295dde5fcba55fe

commit 87bb53cb538059a3085db1fa4295dde5fcba55fe
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-12-12 17:08:39 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-03-21 14:03:12 +0000

    gvinum: correct assertions

    Pointer addresses are always >= 0.  Assert that the value is >= 0
    instead.

    PR:             207855, 207856
    Reviewed by:    imp
    Reported by:    David Binderman
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D37677

 sys/geom/vinum/geom_vinum_plex.c  | 2 +-
 sys/geom/vinum/geom_vinum_raid5.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-03-23 12:43:03 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=66f3ac8c661df02cf7d9e187ea20e66e2e71ec82

commit 66f3ac8c661df02cf7d9e187ea20e66e2e71ec82
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-12-12 17:08:39 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-03-23 12:41:35 +0000

    gvinum: correct assertions

    Pointer addresses are always >= 0.  Assert that the value is >= 0
    instead.

    PR:             207855, 207856
    Reviewed by:    imp
    Reported by:    David Binderman
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D37677

    (cherry picked from commit 87bb53cb538059a3085db1fa4295dde5fcba55fe)

 sys/geom/vinum/geom_vinum_plex.c  | 2 +-
 sys/geom/vinum/geom_vinum_raid5.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-03-23 12:51:10 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=12be1c744e002b96c3b84e816e8ec72455f443bf

commit 12be1c744e002b96c3b84e816e8ec72455f443bf
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-12-12 17:08:39 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-03-23 12:49:43 +0000

    gvinum: correct assertions

    Pointer addresses are always >= 0.  Assert that the value is >= 0
    instead.

    PR:             207855, 207856
    Reviewed by:    imp
    Reported by:    David Binderman
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D37677

    (cherry picked from commit 87bb53cb538059a3085db1fa4295dde5fcba55fe)
    (cherry picked from commit 66f3ac8c661df02cf7d9e187ea20e66e2e71ec82)

 sys/geom/vinum/geom_vinum_plex.c  | 2 +-
 sys/geom/vinum/geom_vinum_raid5.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
Comment 6 Ed Maste freebsd_committer freebsd_triage 2023-03-23 12:55:02 UTC
Now fixed in all supported branches. Thanks for the bug report.