|Summary:||pci_device_linux_sysfs_read_rom refuses to read valid rom, if zero sized|
|Product:||xorg||Reporter:||Stuart Bennett <sb476>|
|Component:||Lib/pciaccess||Assignee:||Xorg Project Team <xorg-team>|
|Status:||RESOLVED FIXED||QA Contact:||Xorg Project Team <xorg-team>|
|i915 platform:||i915 features:|
|Bug Depends on:|
Description Stuart Bennett 2008-01-09 06:55:54 UTC
In pci_create_sysfs_dev_files of Linux's drivers/pci/pci-sysfs.c, the sysfs "rom" file can be created with a zero size (the (pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW) case). The resulting file in sysfs may still be read for a valid rom image. libpciaccess' pci_device_linux_sysfs_read_rom uses the size returned by fstat to determine how many bytes to read, and so in this case reads nothing (and still returns 0 for success). Ideally pci_device_linux_sysfs_read_rom needs adaptation to avoid the fstat result, but falling through to pci_device_linux_devmem_read_rom would also work.
Comment 1 Adam Jackson 2008-02-29 13:49:29 UTC
*** Bug 8698 has been marked as a duplicate of this bug. ***
Comment 2 David Nusinow 2008-03-01 10:46:07 UTC
Created attachment 14736 [details] [review] Proposed patch. Please review.
Comment 3 Stuart Bennett 2008-03-10 15:28:54 UTC
Created attachment 15015 [details] [review] Fix the original problem, and a similar bug in the devmem path The previous patch doesn't work, due to a very similar bug in the handling of zero reported size ROMs in the devmem path. This patch fixes the error in the devmem path, and avoids the fall-through from sysfs to devmem for this particular case by applying the trivial fix that is in the devmem path to the sysfs path. With these fixes, both paths work.
Comment 4 Adam Jackson 2008-03-14 09:08:13 UTC
My name is ajax, and I approve this message. Fixed in git, will be in the next pciaccess release. Thanks!