Re: [PATCH] hwmon: occ: fix unaligned accesses

From: Guenter Roeck
Date: Tue Jun 10 2025 - 16:52:58 EST


On Tue, Jun 10, 2025 at 11:25:49AM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@xxxxxxxx>
>
> Passing a pointer to an unaligned integer as a function argument is
> undefined behavior:
>
> drivers/hwmon/occ/common.c:492:27: warning: taking address of packed member 'accumulator' of class or structure 'power_sensor_2' may result in an unaligned pointer value [-Waddress-of-packed-member]
> 492 | val = occ_get_powr_avg(&power->accumulator,
> | ^~~~~~~~~~~~~~~~~~
> drivers/hwmon/occ/common.c:493:13: warning: taking address of packed member 'update_tag' of class or structure 'power_sensor_2' may result in an unaligned pointer value [-Waddress-of-packed-member]
> 493 | &power->update_tag);
> | ^~~~~~~~~~~~~~~~~
>
> Move the get_unaligned() calls out of the function and pass these
> through argument registers instead.
>
> Fixes: c10e753d43eb ("hwmon (occ): Add sensor types and versions")
> Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>

Applied.

Thanks,
Guenter