We should only sort the mockup chip pointers after determining that
all gpiochip device files have actually been created. Otherwise we
might sort invalid memory since we don't create the mockup_chip
structures for nonexistent devices.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
}
}
- qsort(ctx->chips, ctx->num_chips, sizeof(*ctx->chips), chipcmp);
-
if (descr->num_chips != current)
die("number of requested and detected mockup gpiochips is not the same");
+ qsort(ctx->chips, ctx->num_chips, sizeof(*ctx->chips), chipcmp);
+
closedir(dir);
}