Skip to content

Commit

Permalink
src/crush: check before dereference out2
Browse files Browse the repository at this point in the history
CID 174874 (#2 of 2): Dereference after null check (FORWARD_NULL)
30. var_deref_op: Dereference null pointer out2.

Signed-off-by: songweibin <song.weibin@zte.com.cn>
  • Loading branch information
Songweibin committed Jul 26, 2019
1 parent 0c70668 commit e027012
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/crush/mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,11 +792,11 @@ static void crush_choose_indep(const struct crush_map *map,
out2, rep,
recurse_tries, 0,
0, NULL, r, choose_args);
if (out2[rep] == CRUSH_ITEM_NONE) {
if (out2 && out2[rep] == CRUSH_ITEM_NONE) {
/* placed nothing; no leaf */
break;
}
} else {
} else if (out2) {
/* we already have a leaf! */
out2[rep] = item;
}
Expand Down

0 comments on commit e027012

Please sign in to comment.