summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLyude Paul <lyude@redhat.com>2020-10-09 13:50:56 -0400
committerLyude Paul <lyude@redhat.com>2020-10-12 18:01:34 -0400
commit9ed6aa677660008f3619cff5dce7f1949d1c73bf (patch)
tree79a7560d4d05ed63aab2fd2aefb523c60ea0ab31
parent836f8812f0e6c44674c1c75501640eabbdd8918a (diff)
lib/igt_device_scan: init card in igt_device_find_first_i915_discrete_card()
Because we never initialize the card pointer passed to igt_device_find_first_i915_discrete_card() if we don't match any cards, we make the mistake of checking the contents of card in main() in intel_gpu_top.c before they've actually been initialized, which can lead to a segfault in some scenarios: # intel_gpu_top intel_gpu_top: ../tools/intel_gpu_top.c:1297: tr_pmu_name: Assertion `ret == (bufsize-1)' failed. abort--core dumped So, fix it by making sure to initialize card in igt_device_find_first_i915_discrete_card() like we do in igt_device_card_match(). Signed-off-by: Lyude Paul <lyude@redhat.com> Reported-by: Chris Siebenmann <cks-rhbugzilla@cs.toronto.edu> Cc: Zbigniew KempczyƄski <zbigniew.kempczynski@intel.com> Fedora bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1884016
-rw-r--r--lib/igt_device_scan.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
index 345bae76d..d77311a40 100644
--- a/lib/igt_device_scan.c
+++ b/lib/igt_device_scan.c
@@ -453,6 +453,8 @@ void igt_device_find_first_i915_discrete_card(struct igt_device_card *card)
{
struct igt_device *dev;
+ memset(card, 0, sizeof(*card));
+
igt_list_for_each_entry(dev, &igt_devs.all, link) {
if (!is_pci_subsystem(dev))