HomeFreeBSD

radix_mpath: Don't derefence a NULL pointer in for loop iteration

Description

radix_mpath: Don't derefence a NULL pointer in for loop iteration

It seems rn_dupedkey may be NULL, because of the NULL check inside the loop.
(Also, the rt gets assigned from rn_dupedkey and NULL checked at top of loop.)
However, the for-loop update condition happens before the top-of-loop check and
dereferences 'rt' unconditionally.

Instead, NULL-check before dereferencing.

If rn_dupedkey cannot in fact be NULL, or something else protects this, feel
free to revert this and add an ASSERT of some kind instead.

This was introduced in r191080 (2009) and moved around slightly in r293657.

Reported by: Coverity
CID: 1348482
Sponsored by: EMC / Isilon Storage Division

Details

Provenance
cemAuthored on
Parents
rS298662: PCI Enhanced Allocation: Annotate an intentional switch fallthrough
Branches
Unknown
Tags
Unknown