From 594de878074827e0c0f6b5ee794fe433727ced64 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 5 Oct 2007 12:37:16 +0200 Subject: [PATCH] Detect and report loops in capability lists. --- ChangeLog | 5 +++++ lspci.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index 69ea70f..daf3534 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-10-05 Martin Mares + + * lspci.c (show_caps, show_ext_caps): Detect and report loops in + capability lists. + 2007-09-12 Hasso Tepper * Extended the fbsd-device backend to run on Dragonfly BSD. diff --git a/lspci.c b/lspci.c index f02219b..2576068 100644 --- a/lspci.c +++ b/lspci.c @@ -1374,6 +1374,8 @@ static void show_ext_caps(struct device *d) { int where = 0x100; + char been_there[0x1000]; + memset(been_there, 0, 0x1000); do { u32 header; @@ -1386,6 +1388,11 @@ show_ext_caps(struct device *d) break; id = header & 0xffff; printf("\tCapabilities: [%03x] ", where); + if (been_there[where++]) + { + printf("\n"); + break; + } switch (id) { case PCI_EXT_CAP_ID_AER: @@ -1416,6 +1423,8 @@ show_caps(struct device *d) if (get_conf_word(d, PCI_STATUS) & PCI_STATUS_CAP_LIST) { int where = get_conf_byte(d, PCI_CAPABILITY_LIST) & ~3; + byte been_there[256]; + memset(been_there, 0, 256); while (where) { int id, next, cap; @@ -1429,6 +1438,11 @@ show_caps(struct device *d) next = get_conf_byte(d, where + PCI_CAP_LIST_NEXT) & ~3; cap = get_conf_word(d, where + PCI_CAP_FLAGS); printf("[%02x] ", where); + if (been_there[where]++) + { + printf("\n"); + break; + } if (id == 0xff) { printf("\n"); -- 2.39.5