Skip to content

sysfs error unhandled in fpgasupdate #3139

@ifkato

Description

@ifkato

Some sysfs objects of the dfl/intel-m10bmc driver can return -EINVAL when read.
In this case, reading the fpga_boot_page file results in -EINVAL if PMCI_CONFIGED bit of the PMCI CSR M10BMC_PMCI_FPGA_CONF_STS word is 0.
(i.e. the FPGA failed to be configured from FLASH, but is configured from JTAG.)

https://github.com/OFS/linux-dfl/blob/6b0d820d436dda1e5949205a8f081fe0360c8430/drivers/fpga/intel-m10-bmc-sec-update.c#L1105

sysfs_node#value() method opens and reads the fpga_boot_page file.
It handles and raises IOError.
It does not handle OSError from -EINVAL.

@property
def value(self):
"""value Read the value of a sysfs attribute
Returns: The string returned (trimmed of whitespace) from reading the
attribute.
Raises:
IOError: If an IOError is caught while attempting to open the path
object represented by this node.
Note:
Attempting to get a value from a sysfs path that is a directory
will result in an IOError being raised.
"""
try:
with self._open('r') as fd:
return fd.read().strip()
except IOError as err:
self.log.exception('error opening: %s - %s', self.sysfs_path, err)
raise

fpgasupdate calls sysfs_node#value() without handling OSError or IOError, so it crashes if the FPGA is configured from JTAG.

LOG.debug ("Boot page value: %s\n", boot_page.value)

To fix this, some error handling needs to be implemented, either in sysfs_node class or fpgasupdate.py.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions