# Re: \[PATCH v2 6/5\] Fix unaligned memory accesses in dmi-sysfs

- From: Greg KH \<hidden\>
- Date: 2011-02-25 23:20:54 
- List: linux-api
- Page: https://ratatoskr.run/linux-api/2011/02/3683024
- Thread: https://ratatoskr.run/linux-api/2011/02/3681559/t.md

```text
On Fri, Feb 25, 2011 at 03:06:25PM -0800, Mike Waychison wrote:
> DMI entries are arranged in memory back to back with no alignment
> guarantees. This means that the struct dmi_header passed to callbacks
> from dmi_walk() itself isn't byte aligned.  This causes problems on
> architectures that expect aligned data, such as IA64.
> 
> The dmi-sysfs patchset introduced structure member accesses through
> this passed in dmi_header.  Fix this by memcpy()ing the structures to
> temporary locations on stack when inspecting/copying them.
> 
> Signed-off-by: Mike Waychison <redacted>
> Tested-by: Tony Luck <redacted>
> ---
>  dmi-sysfs.c |   28 +++++++++++++---------------
>  1 file changed, 13 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c
> index a5afd80..eb26d62 100644
> --- a/drivers/firmware/dmi-sysfs.c
> +++ b/drivers/firmware/dmi-sysfs.c
> @@ -263,20 +263,16 @@ struct dmi_system_event_log {
>  	u8	supported_log_type_descriptos[0];
>  } __packed;
> 
> -static const struct dmi_system_event_log *to_sel(const struct
> dmi_header *dh)

This patch is corrupted.  I tried to edit it by hand, but git still
didn't like it.

Please resend using whatever you did for your other patches, as this way
was not correct :(

thanks,

greg k-h
```
