Skip to contentSkip to conversation

reset: brcmstb: Fix resource checks

PATCH In review Florian Fainelli 1 participant 2 messages Nov 1, 2019

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

PATCH v2 1/1 reset: brcmstb: Fix resource checks

The use of IS_ALIGNED() is incorrect, the typical resource we pass looks like this: start: 0x8404318, size: 0x30. When using IS_ALIGNED() we will get the following 0x8404318 & (0x18 - 1) = 0x10 which is definitively not equal to 0, same goes with the size.

Replace this with an appropriate check on the start address and the resource size to be a multiple of SW_INIT_BANK_SIZE.

Fixes 77750bc089e4 ("reset: Add Broadcom STB SW_INIT reset controller driver")

---
Changes in v2:

- simply check that the resource size is at least SW_INIT_BANK_SIZE

 drivers/reset/reset-brcmstb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/reset/reset-brcmstb.c +2 -2
index a608f445dad6..208a87aaee53 100644
@@ -91,8 +91,8 @@ static int brcmstb_reset_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!IS_ALIGNED(res->start, SW_INIT_BANK_SIZE) ||
-	    !IS_ALIGNED(resource_size(res), SW_INIT_BANK_SIZE)) {
+	if ((res->start & SW_INIT_BANK_SIZE) != SW_INIT_BANK_SIZE ||
+	    !DIV_ROUND_DOWN_ULL(resource_size(res), SW_INIT_BANK_SIZE)) {
 		dev_err(kdev, "incorrect register range\n");
 		return -EINVAL;
 	}
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw
Quoted 10 lines · Florian Fainelli

The use of IS_ALIGNED() is incorrect, the typical resource we pass looks like this: start: 0x8404318, size: 0x30. When using IS_ALIGNED() we will get the following 0x8404318 & (0x18 - 1) = 0x10 which is definitively not equal to 0, same goes with the size.

Replace this with an appropriate check on the start address and the resource size to be a multiple of SW_INIT_BANK_SIZE.

Fixes 77750bc089e4 ("reset: Add Broadcom STB SW_INIT reset controller driver")

Philipp, I am just going to remove those register checks, this is overly cautious for no particular reason, and we actually have platforms where those registers checks would just flat out fail. Expect a v3 shortly, thanks!

Signature · 1 line
Florian