Check the validity of the PCI device string in AMD ADL I2C driver to prevent crash if the string is malformed
This commit is contained in:
parent
f977598392
commit
4fa5b413ee
1 changed files with 16 additions and 13 deletions
|
|
@ -84,6 +84,8 @@ i2c_smbus_amdadl::i2c_smbus_amdadl(ADL_CONTEXT_HANDLE context)
|
|||
std::size_t dev_loc = pnp_str.find("DEV_");
|
||||
std::size_t sub_loc = pnp_str.find("SUBSYS_");
|
||||
|
||||
if((ven_loc != std::string::npos) && (dev_loc != std::string::npos) && (sub_loc != std::string::npos))
|
||||
{
|
||||
std::string ven_str = pnp_str.substr(ven_loc + 4, 4);
|
||||
std::string dev_str = pnp_str.substr(dev_loc + 4, 4);
|
||||
std::string sbv_str = pnp_str.substr(sub_loc + 11, 4);
|
||||
|
|
@ -101,6 +103,7 @@ i2c_smbus_amdadl::i2c_smbus_amdadl(ADL_CONTEXT_HANDLE context)
|
|||
strcpy(this->device_name, "AMD ADL");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s32 i2c_smbus_amdadl::i2c_smbus_xfer(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue