From: Andrew Morton Date: Wed, 1 Feb 2006 11:05:02 +0000 (-0800) Subject: [PATCH] tpm_bios indexing fix X-Git-Tag: v2.6.16-rc2~141 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c40f7d4f0a9d5242f19b02b00e3e5a8ee218a20;p=linux-2.6 [PATCH] tpm_bios indexing fix It generates warnings: drivers/char/tpm/tpm_bios.c: In function `get_event_name': drivers/char/tpm/tpm_bios.c:223: warning: cast from pointer to integer of different size drivers/char/tpm/tpm_bios.c:223: warning: cast from pointer to integer of different size drivers/char/tpm/tpm_bios.c:223: warning: cast from pointer to integer of different size drivers/char/tpm/tpm_bios.c:224: warning: cast from pointer to integer of different size drivers/char/tpm/tpm_bios.c:224: warning: cast from pointer to integer of different size drivers/char/tpm/tpm_bios.c:224: warning: cast from pointer to integer of different size and I'm not sure what the code is doing there, but it seems wrong. We're using the address of the buffer rather than the contents of it. The patch adds more nasty typecasting, but I think the whole arrangement could be done in a more typesafe manner. Cc: Kylene Jo Hall Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c index 9ffa5643e7..1310189fd9 100644 --- a/drivers/char/tpm/tpm_bios.c +++ b/drivers/char/tpm/tpm_bios.c @@ -220,8 +220,8 @@ static int get_event_name(char *dest, struct tcpa_event *event, } break; case EVENT_TAG: - event_id = be32_to_cpu(event_entry); - event_data_size = be32_to_cpu(&event_entry[4]); + event_id = be32_to_cpu(*((u32 *)event_entry)); + event_data_size = be32_to_cpu(((u32 *)event_entry)[1]); /* ToDo Row data -> Base64 */