Bug 13988 - pci_device_linux_sysfs_read_rom refuses to read valid rom, if zero sized
Summary: pci_device_linux_sysfs_read_rom refuses to read valid rom, if zero sized
Alias: None
Product: xorg
Classification: Unclassified
Component: Lib/pciaccess (show other bugs)
Version: git
Hardware: Other Linux (All)
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
: 8698 (view as bug list)
Depends on:
Blocks: xorg-7.4
  Show dependency treegraph
Reported: 2008-01-09 06:55 UTC by Stuart Bennett
Modified: 2008-03-14 09:08 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

Proposed patch. Please review. (866 bytes, patch)
2008-03-01 10:46 UTC, David Nusinow
no flags Details | Splinter Review
Fix the original problem, and a similar bug in the devmem path (1.93 KB, patch)
2008-03-10 15:28 UTC, Stuart Bennett
no flags Details | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.