On 08/09/2016 17:58, George Wilson wrote:
> It can't be NULL in this code path. It can only be NULL when you first select
> the metaslab group that you're going to attempt to allocate from.
George,
thank you for the reply.
Just to be sure, do we need to check mg_next for being NULL in the following
code in metaslab_alloc_dva():
if (hintdva) {
vd = vdev_lookup_top(spa, DVA_GET_VDEV(&hintdva[d]));
/*
* It's possible the vdev we're using as the hint no
* longer exists (i.e. removed). Consult the rotor when
* all else fails.
*/
if (vd != NULL) {
mg = vd->vdev_mg;
if (flags & METASLAB_HINTBP_AVOID &&
mg->mg_next != NULL)
mg = mg->mg_next;
} else {
mg = mc->mc_rotor;
}
} else if (d != 0) {
> On Thu, Sep 8, 2016 at 10:26 AM, Andriy Gapon <[email protected]
> <mailto:[email protected]>> wrote:
>
> Can mg_next even be NULL?
> There is some code that checks for that condition and, thus, Coverity assumes
> that it can be true. Based on that assumption it quite convincingly proves
> that
> there could be a NULL pointer dereference in metaslab_group_allocatable()
> where
> we have the following loop:
>
> for (mgp = mg->mg_next; mgp != rotor; mgp = mgp->mg_next) {
> ...
> }
>
> --
> Andriy Gapon
>
> *openzfs-developer* | Archives
> <https://www.listbox.com/member/archive/274414/=now>
> <https://www.listbox.com/member/archive/rss/274414/28133750-22ed9730> | Modify
> <https://www.listbox.com/member/?&>
> Your Subscription [Powered by Listbox] <http://www.listbox.com>
--
Andriy Gapon
-------------------------------------------
openzfs-developer
Archives: https://www.listbox.com/member/archive/274414/=now
RSS Feed: https://www.listbox.com/member/archive/rss/274414/28015062-cce53afa
Modify Your Subscription:
https://www.listbox.com/member/?member_id=28015062&id_secret=28015062-f966d51c
Powered by Listbox: http://www.listbox.com