platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] platform/surface: tabletsw: Fix __le32 integer access
@ 2022-07-17 12:07 Maximilian Luz
  2022-07-17 14:50 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Maximilian Luz @ 2022-07-17 12:07 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mark Gross, platform-driver-x86, linux-kernel, Maximilian Luz,
	kernel test robot

The sources.count field is a __le32 inside a packed struct. So use the
proper functions to access it.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 9f794056db5b ("platform/surface: Add KIP/POS tablet-mode switch driver")
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
---
 drivers/platform/surface/surface_aggregator_tabletsw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
index 596ca6c80681..27d95a6a7851 100644
--- a/drivers/platform/surface/surface_aggregator_tabletsw.c
+++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
@@ -410,7 +410,7 @@ static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id)
 	if (status)
 		return status;
 
-	if (sources.count == 0) {
+	if (get_unaligned_le32(&sources.count) == 0) {
 		dev_err(&sw->sdev->dev, "no posture sources found\n");
 		return -ENODEV;
 	}
@@ -422,7 +422,7 @@ static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id)
 	 * is a device that provides multiple sources, at which point we can
 	 * then try to figure out how to handle them.
 	 */
-	WARN_ON(sources.count > 1);
+	WARN_ON(get_unaligned_le32(&sources.count) > 1);
 
 	*source_id = get_unaligned_le32(&sources.id[0]);
 	return 0;
-- 
2.37.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] platform/surface: tabletsw: Fix __le32 integer access
  2022-07-17 12:07 [PATCH] platform/surface: tabletsw: Fix __le32 integer access Maximilian Luz
@ 2022-07-17 14:50 ` Hans de Goede
  0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2022-07-17 14:50 UTC (permalink / raw)
  To: Maximilian Luz
  Cc: Mark Gross, platform-driver-x86, linux-kernel, kernel test robot

Hi,

On 7/17/22 14:07, Maximilian Luz wrote:
> The sources.count field is a __le32 inside a packed struct. So use the
> proper functions to access it.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: 9f794056db5b ("platform/surface: Add KIP/POS tablet-mode switch driver")
> Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans


> ---
>  drivers/platform/surface/surface_aggregator_tabletsw.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c
> index 596ca6c80681..27d95a6a7851 100644
> --- a/drivers/platform/surface/surface_aggregator_tabletsw.c
> +++ b/drivers/platform/surface/surface_aggregator_tabletsw.c
> @@ -410,7 +410,7 @@ static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id)
>  	if (status)
>  		return status;
>  
> -	if (sources.count == 0) {
> +	if (get_unaligned_le32(&sources.count) == 0) {
>  		dev_err(&sw->sdev->dev, "no posture sources found\n");
>  		return -ENODEV;
>  	}
> @@ -422,7 +422,7 @@ static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id)
>  	 * is a device that provides multiple sources, at which point we can
>  	 * then try to figure out how to handle them.
>  	 */
> -	WARN_ON(sources.count > 1);
> +	WARN_ON(get_unaligned_le32(&sources.count) > 1);
>  
>  	*source_id = get_unaligned_le32(&sources.id[0]);
>  	return 0;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-17 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-17 12:07 [PATCH] platform/surface: tabletsw: Fix __le32 integer access Maximilian Luz
2022-07-17 14:50 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).