]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
src/crush: check before dereference out2
authorsongweibin <song.weibin@zte.com.cn>
Thu, 25 Jul 2019 10:55:39 +0000 (18:55 +0800)
committersongweibin <song.weibin@zte.com.cn>
Fri, 26 Jul 2019 06:27:02 +0000 (14:27 +0800)
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>
src/crush/mapper.c

index 73f92a77d9f220e0e0989e9d223166cea9b8c3bb..4ac57262716a5f2887f7ec03a377bedef89b76f7 100644 (file)
@@ -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;
                                        }