Skip to content

Commit 3d3d90e

Browse files
committed
Mask set and way parameters before shifting to prevent overflow
1 parent 56febf4 commit 3d3d90e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/peripheral/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ impl Cbp {
10201020
// CMSIS-Core implementation and use fixed values.
10211021
unsafe { self.dcisw.write(
10221022
(((way as u32) & (CBP_SW_WAY_MASK >> CBP_SW_WAY_POS)) << CBP_SW_WAY_POS) |
1023-
(((set as u32) & (CBP_SW_SET_MASK >> CBP_SW_SET_POS)) << CBP_SW_SET_POS);
1023+
(((set as u32) & (CBP_SW_SET_MASK >> CBP_SW_SET_POS)) << CBP_SW_SET_POS));
10241024
}
10251025
}
10261026

@@ -1044,7 +1044,7 @@ impl Cbp {
10441044
// See comment for dcisw() about the format here
10451045
unsafe { self.dccsw.write(
10461046
(((way as u32) & (CBP_SW_WAY_MASK >> CBP_SW_WAY_POS)) << CBP_SW_WAY_POS) |
1047-
(((set as u32) & (CBP_SW_SET_MASK >> CBP_SW_SET_POS)) << CBP_SW_SET_POS);
1047+
(((set as u32) & (CBP_SW_SET_MASK >> CBP_SW_SET_POS)) << CBP_SW_SET_POS));
10481048
}
10491049
}
10501050

@@ -1062,7 +1062,7 @@ impl Cbp {
10621062
// See comment for dcisw() about the format here
10631063
unsafe { self.dccisw.write(
10641064
(((way as u32) & (CBP_SW_WAY_MASK >> CBP_SW_WAY_POS)) << CBP_SW_WAY_POS) |
1065-
(((set as u32) & (CBP_SW_SET_MASK >> CBP_SW_SET_POS)) << CBP_SW_SET_POS);
1065+
(((set as u32) & (CBP_SW_SET_MASK >> CBP_SW_SET_POS)) << CBP_SW_SET_POS));
10661066
}
10671067
}
10681068

0 commit comments

Comments
 (0)