Skip to content

Commit f2767a4

Browse files
kmaincentlunn
authored andcommitted
net: pse-pd: Fix out of bound for loop
Adjust the loop limit to prevent out-of-bounds access when iterating over PI structures. The loop should not reach the index pcdev->nr_lines since we allocate exactly pcdev->nr_lines number of PI structures. This fix ensures proper bounds are maintained during iterations. Fixes: 9be9567 ("net: pse-pd: Add support for PSE PIs") Signed-off-by: Kory Maincent <[email protected]> Reviewed-by: Simon Horman <[email protected]> Acked-by: Oleksij Rempel <[email protected]> Message-ID: <[email protected]> Signed-off-by: Andrew Lunn <[email protected]>
1 parent 07d6bf6 commit f2767a4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/pse-pd/pse_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static void pse_release_pis(struct pse_controller_dev *pcdev)
113113
{
114114
int i;
115115

116-
for (i = 0; i <= pcdev->nr_lines; i++) {
116+
for (i = 0; i < pcdev->nr_lines; i++) {
117117
of_node_put(pcdev->pi[i].pairset[0].np);
118118
of_node_put(pcdev->pi[i].pairset[1].np);
119119
of_node_put(pcdev->pi[i].np);
@@ -647,7 +647,7 @@ static int of_pse_match_pi(struct pse_controller_dev *pcdev,
647647
{
648648
int i;
649649

650-
for (i = 0; i <= pcdev->nr_lines; i++) {
650+
for (i = 0; i < pcdev->nr_lines; i++) {
651651
if (pcdev->pi[i].np == np)
652652
return i;
653653
}

0 commit comments

Comments
 (0)