Skip to contentSkip to conversation

ntb_hw_switchtec: potential shift wrapping bug in switchtec_ntb_init_sndev()

PATCH In review Dan Carpenter 3 participants 3 messages Mar 25, 2019 – Jun 13, 2019

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

PATCH 1/1 ntb_hw_switchtec: potential shift wrapping bug in switchtec_ntb_init_sndev()

This code triggers a Smatch warning:

    drivers/ntb/hw/mscc/ntb_hw_switchtec.c:884 switchtec_ntb_init_sndev()
    warn: should '(1 << sndev->peer_partition)' be a 64 bit type?

The "part_map" and "tpart_vec" variables are u64 type so this seems like a valid warning.

Fixes 3df54c870f52 ("ntb_hw_switchtec: Allow using Switchtec NTB in multi-partition setups")
---
 drivers/ntb/hw/mscc/ntb_hw_switchtec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ntb/hw/mscc/ntb_hw_switchtec.c +1 -1
index d905d368d28c..26a88731b0cb 100644
@@ -881,7 +881,7 @@ static int switchtec_ntb_init_sndev(struct switchtec_ntb *sndev)
 		}
 
 		sndev->peer_partition = ffs(tpart_vec) - 1;
-		if (!(part_map & (1 << sndev->peer_partition))) {
+		if (!(part_map & (1ULL << sndev->peer_partition))) {
 			dev_err(&sndev->stdev->dev,
 				"ntb target partition is not NT partition\n");
 			return -ENODEV;
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Thanks!

Quoted 10 lines · Dan Carpenter

This code triggers a Smatch warning:

    drivers/ntb/hw/mscc/ntb_hw_switchtec.c:884 switchtec_ntb_init_sndev()
    warn: should '(1 << sndev->peer_partition)' be a 64 bit type?

The "part_map" and "tpart_vec" variables are u64 type so this seems like a valid warning.

Fixes 3df54c870f52 ("ntb_hw_switchtec: Allow using Switchtec NTB in multi-partition setups")
maintainer
#2 lore raw
Quoted 8 lines · Logan Gunthorpe

Thanks!

Quoted 5 lines · Dan Carpenter

This code triggers a Smatch warning:

    drivers/ntb/hw/mscc/ntb_hw_switchtec.c:884 switchtec_ntb_init_sndev()
    warn: should '(1 << sndev->peer_partition)' be a 64 bit type?
Quoted 7 lines
Quoted 5 lines

The "part_map" and "tpart_vec" variables are u64 type so this seems like a valid warning.

Fixes 3df54c870f52 ("ntb_hw_switchtec: Allow using Switchtec NTB in multi-partition setups")

Sorry for the delay. The patch is now in the ntb branch. We've missed window for 5.2, but it will be in the 5.3 pull request.

Thanks,
Jon

Quoted 7 lines
Signature · 6 lines
-- 
You received this message because you are subscribed to the Google Groups "linux-ntb" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/linux-ntb/e2bc8cf0-8e3e-9335-e21b-4a9697e9c0ef%40deltatee.com.
For more options, visit https://groups.google.com/d/optout.