[Bug 263371] Possible memleak bugs caused by g_raid_destroy_volume()

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 17 Apr 2022 16:02:03 UTC

            Bug ID: 263371
           Summary: Possible memleak bugs caused by
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: zhou1615@umn.edu

In sys/geom/raid/g_raid.c file, the function g_raid_destroy_volume(vol) will
free "vol" on some paths and return EBUSY instead of 0.

However, not all caller of g_raid_destroy_volume() will check the return value
those callers assume that there is no error when running 

In detail, functions below does not check the return value:

In sys/geom/raid/md_promise.c file,
function: g_raid_md_promise_purge_volumes() and g_raid_md_ctl_promise()

In sys/geom/raid/md_ddf.c file,
fucntion: g_raid_md_ddf_purge_volumes() and g_raid_md_ctl_ddf()

In sys/geom/raid/md_intel.c file,
function: g_raid_md_ctl_intel()

In sys/geom/raid/g_raid.c file,
function: g_raid_update_volume() and g_raid_access().

There only one function g_raid_destroy_node() checks the return value of 
g_raid_destroy_volume() and return EBUSY.
Maybe we should handle other functions like this one.

I am not sure whether missing checks of g_raid_destroy_volume() is on purpose 
or ignored,
and those bugs are found by a static analyzer, please advise.

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