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
This commit is contained in:
parent
517960dc84
commit
dcbee68850
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298663
@ -223,7 +223,7 @@ rt_mpath_selectrte(struct rtentry *rte, uint32_t hash)
|
||||
hash %= total_weight;
|
||||
for (weight = abs((int32_t)hash);
|
||||
rt != NULL && weight >= rt->rt_weight;
|
||||
weight -= rt->rt_weight) {
|
||||
weight -= (rt == NULL) ? 0 : rt->rt_weight) {
|
||||
|
||||
/* stay within the multipath routes */
|
||||
if (rn->rn_dupedkey && rn->rn_mask != rn->rn_dupedkey->rn_mask)
|
||||
|
Loading…
Reference in New Issue
Block a user