Skip to contentSkip to conversation

platform/surface: aggregator: fix a bit test

PATCH In review Dan Carpenter 3 participants 3 messages Apr 20, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/surface: aggregator: fix a bit test

The "funcs" variable is a u64. If "func" is more than 31 then the BIT() shift will wrap instead of testing the high bits.

Fixes c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")
---
 drivers/platform/surface/aggregator/controller.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/surface/aggregator/controller.c +1 -1
index 00e38284885a..69e86cd599d3 100644
@@ -1040,7 +1040,7 @@ static int ssam_dsm_load_u32(acpi_handle handle, u64 funcs, u64 func, u32 *ret)
 	union acpi_object *obj;
 	u64 val;
 
-	if (!(funcs & BIT(func)))
+	if (!(funcs & BIT_ULL(func)))
 		return 0; /* Not supported, leave *ret at its default value */
 
 	obj = acpi_evaluate_dsm_typed(handle, &SSAM_SSH_DSM_GUID,
Signature · 1 line
2.30.2
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Dan Carpenter

The "funcs" variable is a u64. If "func" is more than 31 then the BIT() shift will wrap instead of testing the high bits.

Fixes c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")

Thanks!

Quoted 18 lines
---
  drivers/platform/surface/aggregator/controller.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/surface/aggregator/controller.c +1 -1
index 00e38284885a..69e86cd599d3 100644
@@ -1040,7 +1040,7 @@ static int ssam_dsm_load_u32(acpi_handle handle, u64 funcs, u64 func, u32 *ret)
  	union acpi_object *obj;
  	u64 val;
 
-	if (!(funcs & BIT(func)))
+	if (!(funcs & BIT_ULL(func)))
  		return 0; /* Not supported, leave *ret at its default value */
 
  	obj = acpi_evaluate_dsm_typed(handle, &SSAM_SSH_DSM_GUID,
#2 lore raw
In reply to Dan Carpenter

Hi,

Quoted 6 lines · Dan Carpenter

The "funcs" variable is a u64. If "func" is more than 31 then the BIT() shift will wrap instead of testing the high bits.

Fixes c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")

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

Quoted 18 lines
---
 drivers/platform/surface/aggregator/controller.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/surface/aggregator/controller.c +1 -1
index 00e38284885a..69e86cd599d3 100644
@@ -1040,7 +1040,7 @@ static int ssam_dsm_load_u32(acpi_handle handle, u64 funcs, u64 func, u32 *ret)
 	union acpi_object *obj;
 	u64 val;
 
-	if (!(funcs & BIT(func)))
+	if (!(funcs & BIT_ULL(func)))
 		return 0; /* Not supported, leave *ret at its default value */
 
 	obj = acpi_evaluate_dsm_typed(handle, &SSAM_SSH_DSM_GUID,