Skip to content

Commit

Permalink
net: pse-pd: Fix out of bound for loop
Browse files Browse the repository at this point in the history
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]>
Signed-off-by: NipaLocal <nipa@local>
  • Loading branch information
kmaincent authored and NipaLocal committed Oct 17, 2024
1 parent b7157fb commit 9305c0d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/pse-pd/pse_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static void pse_release_pis(struct pse_controller_dev *pcdev)
{
int i;

for (i = 0; i <= pcdev->nr_lines; i++) {
for (i = 0; i < pcdev->nr_lines; i++) {
of_node_put(pcdev->pi[i].pairset[0].np);
of_node_put(pcdev->pi[i].pairset[1].np);
of_node_put(pcdev->pi[i].np);
Expand Down Expand Up @@ -647,7 +647,7 @@ static int of_pse_match_pi(struct pse_controller_dev *pcdev,
{
int i;

for (i = 0; i <= pcdev->nr_lines; i++) {
for (i = 0; i < pcdev->nr_lines; i++) {
if (pcdev->pi[i].np == np)
return i;
}
Expand Down

0 comments on commit 9305c0d

Please sign in to comment.