X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fdump.c;h=59cf7ed432d82db7d0ccb8ceded76538533f186c;hb=d9b1b8e350adbaf97713ce50b044f1c63d6a98cf;hp=69a99c82ae3a50897eb6557ac03da43d6a3335b2;hpb=a2bf30a4fd407c55e8172e2f6fd158725ccb90b6;p=pciutils.git diff --git a/lib/dump.c b/lib/dump.c index 69a99c8..59cf7ed 100644 --- a/lib/dump.c +++ b/lib/dump.c @@ -62,7 +62,7 @@ dump_init(struct pci_access *a) struct pci_dev *dev = NULL; int len, mn, bn, dn, fn, i, j; - if (!a) + if (!name) a->error("dump: File name not given."); if (!(f = fopen(name, "r"))) a->error("dump: Cannot open %s: %s", name, strerror(errno)); @@ -70,7 +70,10 @@ dump_init(struct pci_access *a) { char *z = strchr(buf, '\n'); if (!z) - a->error("dump: line too long or unterminated"); + { + fclose(f); + a->error("dump: line too long or unterminated"); + } *z-- = 0; if (z >= buf && *z == '\r') *z-- = 0; @@ -95,7 +98,10 @@ dump_init(struct pci_access *a) sscanf(z, "%x", &j) == 1 && j < 256) { if (i >= 4096) - a->error("dump: At most 4096 bytes of config space are supported"); + { + fclose(f); + a->error("dump: At most 4096 bytes of config space are supported"); + } if (i >= dd->allocated) /* Need to re-allocate the buffer */ { dump_alloc_data(dev, 4096); @@ -111,9 +117,13 @@ dump_init(struct pci_access *a) z++; } if (*z) - a->error("dump: Malformed line"); + { + fclose(f); + a->error("dump: Malformed line"); + } } } + fclose(f); } static void @@ -173,6 +183,7 @@ struct pci_methods pm_dump = { pci_generic_fill_info, dump_read, dump_write, + NULL, /* read_vpd */ NULL, /* init_dev */ dump_cleanup_dev };