From c5860546c4f6cb58a1fcfe43bf876d25f36d5dab Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Wed, 26 Dec 2007 21:50:59 +0000 Subject: [PATCH] Fix some bugs in the FreeBSD 4/5/6 pci(4) IOCTLs compatibility code: - Use the correct offsets when copying out the results of PCIOCGETCONF_OLD. This happened to not affect the 64-bit architectures because there the addition of pc_domain to struct pcisel didn't change the overall size of struct pci_conf. [1] - Always copy the name and unit information to conf_old so it's also part of the output once this information is cached in dinfo. - Use the correct type for flags in struct pci_match_conf_old. This change is more or less cosmetic though. Reported and tested by: bde [1] Reviewed by: imp MFC after: 3 days Committed from: 24C3 --- sys/dev/pci/pci_user.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sys/dev/pci/pci_user.c b/sys/dev/pci/pci_user.c index 80fea0ec892f..0af05a93f381 100644 --- a/sys/dev/pci/pci_user.c +++ b/sys/dev/pci/pci_user.c @@ -215,7 +215,7 @@ struct pci_match_conf_old { u_int16_t pc_vendor; /* PCI Vendor ID */ u_int16_t pc_device; /* PCI Device ID */ u_int8_t pc_class; /* PCI class */ - pci_getconf_flags flags; /* Matching expression */ + pci_getconf_flags_old flags; /* Matching expression */ }; struct pci_io_old { @@ -527,23 +527,20 @@ pci_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *t dinfo->conf.pc_progif; conf_old.pc_revid = dinfo->conf.pc_revid; - conf_old.pd_name[0] = '\0'; - conf_old.pd_unit = 0; - if (name) { - strncpy(conf_old.pd_name, name, - sizeof(conf_old.pd_name)); - conf_old. - pd_name[PCI_MAXNAMELEN] = 0; - conf_old.pd_unit = - dinfo->conf.pd_unit; - } + strncpy(conf_old.pd_name, + dinfo->conf.pd_name, + sizeof(conf_old.pd_name)); + conf_old.pd_name[PCI_MAXNAMELEN] = 0; + conf_old.pd_unit = + dinfo->conf.pd_unit; confdata = &conf_old; } else #endif confdata = &dinfo->conf; /* Only if we can copy it out do we count it. */ if (!(error = copyout(confdata, - &cio->matches[cio->num_matches], confsz))) + (caddr_t)cio->matches + + confsz * cio->num_matches, confsz))) cio->num_matches++; } }