Skip to content

Commit 0c61227

Browse files
Gleb NatapovH. Peter Anvin
authored andcommitted
x86, setup: Fix EDD3.0 data verification.
Check for nonzero path in edd_has_edd30() has no sense. First, it looks at the wrong memory. Device path starts at offset 30 of the info->params structure which is at offset 8 from the beginning of info structure, but code looks at info + 4 instead. This was correct when code was introduced, but around v2.6.4 three more fields were added to edd_info structure (commit 66b61a5 in history.git). Second, even if it will check correct memory it will always succeed since at offset 30 (params->key) there will be non-zero values otherwise previous check would fail. The patch replaces this bogus check with one that verifies checksum. Signed-off-by: Gleb Natapov <gleb@redhat.com> Link: http://lkml.kernel.org/r/20110426082132.GG2265@redhat.com Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
1 parent 8e10cd7 commit 0c61227

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

‎drivers/firmware/edd.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -531,8 +531,8 @@ static int
531531
edd_has_edd30(struct edd_device *edev)
532532
{
533533
struct edd_info *info;
534-
int i, nonzero_path = 0;
535-
char c;
534+
int i;
535+
u8 csum = 0;
536536

537537
if (!edev)
538538
return 0;
@@ -544,16 +544,16 @@ edd_has_edd30(struct edd_device *edev)
544544
return 0;
545545
}
546546

547-
for (i = 30; i <= 73; i++) {
548-
c = *(((uint8_t *) info) + i + 4);
549-
if (c) {
550-
nonzero_path++;
551-
break;
552-
}
553-
}
554-
if (!nonzero_path) {
547+
548+
/* We support only T13 spec */
549+
if (info->params.device_path_info_length != 44)
550+
return 0;
551+
552+
for (i = 30; i < info->params.device_path_info_length + 30; i++)
553+
csum += *(((u8 *)&info->params) + i);
554+
555+
if (csum)
555556
return 0;
556-
}
557557

558558
return 1;
559559
}

0 commit comments

Comments
 (0)