diff options
author | Gleb Natapov <gleb@redhat.com> | 2011-04-26 04:21:32 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2011-04-27 17:16:12 -0400 |
commit | 0c61227094b3ddaca2f847ee287c4a2e3762b5a2 (patch) | |
tree | b9575437608041e1ebce1302ce1fb20902a04656 | |
parent | 8e10cd74342c7f5ce259cceca36f6eba084f5d58 (diff) |
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 66b61a5c 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>
-rw-r--r-- | drivers/firmware/edd.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/firmware/edd.c b/drivers/firmware/edd.c index 96c25d93eed1..f1b7f659d3c9 100644 --- a/drivers/firmware/edd.c +++ b/drivers/firmware/edd.c | |||
@@ -531,8 +531,8 @@ static int | |||
531 | edd_has_edd30(struct edd_device *edev) | 531 | edd_has_edd30(struct edd_device *edev) |
532 | { | 532 | { |
533 | struct edd_info *info; | 533 | struct edd_info *info; |
534 | int i, nonzero_path = 0; | 534 | int i; |
535 | char c; | 535 | u8 csum = 0; |
536 | 536 | ||
537 | if (!edev) | 537 | if (!edev) |
538 | return 0; | 538 | return 0; |
@@ -544,16 +544,16 @@ edd_has_edd30(struct edd_device *edev) | |||
544 | return 0; | 544 | return 0; |
545 | } | 545 | } |
546 | 546 | ||
547 | for (i = 30; i <= 73; i++) { | 547 | |
548 | c = *(((uint8_t *) info) + i + 4); | 548 | /* We support only T13 spec */ |
549 | if (c) { | 549 | if (info->params.device_path_info_length != 44) |
550 | nonzero_path++; | 550 | return 0; |
551 | break; | 551 | |
552 | } | 552 | for (i = 30; i < info->params.device_path_info_length + 30; i++) |
553 | } | 553 | csum += *(((u8 *)&info->params) + i); |
554 | if (!nonzero_path) { | 554 | |
555 | if (csum) | ||
555 | return 0; | 556 | return 0; |
556 | } | ||
557 | 557 | ||
558 | return 1; | 558 | return 1; |
559 | } | 559 | } |