TCG SED features have variable sizes, so the code needs to use
stored length to move the offset for the next feature.
Otherwise, it checks the code at the wrong offset.
Signed-off-by: Milan Broz <gmazyland@gmail.com>
int sedopal_cmd_discover(int fd)
{
#ifdef IOC_OPAL_DISCOVERY
- int rc;
+ int rc, feat_length;
bool sedopal_locking_supported = false;
struct opal_discovery discover;
struct level_0_discovery_header *dh;
*/
while (feat < feat_end) {
code = be16toh(feat->code);
+ feat_length = feat->length + 4 /* hdr */;
switch (code) {
case OPAL_FEATURE_CODE_LOCKING:
locking_flags = feat->feature;
break;
}
- feat++;
+ feat = (struct level_0_discovery_features *)((char *)feat + feat_length);
}
rc = 0;