Skip to content

Commit 3e4f99e

Browse files
committed
drivers: media: pisp_be: Fix use after free in job queue logic
pispbe_schedule() currently takes a node group as a parameter, which is left over from before the job prepare/scheduling refactoring. This is now invalid, as jobs are executed in the order which they were queued. As part of this old code, there was a check if the current node group mached the node group of the job, and if unmathched, use a "continue" statement. This is invalid as there is no loop to iterate over any more. The reason this was not a compile bug is because of the for loop used as part of the scoped_guard macro. A consequence of breaking out of the scoped_guard loop early is that the job structure gets freed, but not actually removed from the queue and may be accessed after freeing. Fix this by removing the node group test in pispbe_schedule() as it is no longer valid to use. Signed-off-by: Naushir Patuck <[email protected]>
1 parent 1506a5e commit 3e4f99e

File tree

1 file changed

+4
-9
lines changed
  • drivers/media/platform/raspberrypi/pisp_be

1 file changed

+4
-9
lines changed

drivers/media/platform/raspberrypi/pisp_be/pisp_be.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,7 @@ static int pispbe_prepare_job(struct pispbe_node_group *node_group)
594594
return -ENODEV;
595595
}
596596

597-
static void pispbe_schedule(struct pispbe_dev *pispbe,
598-
struct pispbe_node_group *node_group,
599-
bool clear_hw_busy)
597+
static void pispbe_schedule(struct pispbe_dev *pispbe, bool clear_hw_busy)
600598
{
601599
struct pispbe_job_descriptor *job;
602600

@@ -613,9 +611,6 @@ static void pispbe_schedule(struct pispbe_dev *pispbe,
613611
if (!job)
614612
return;
615613

616-
if (node_group && job->node_group != node_group)
617-
continue;
618-
619614
list_del(&job->queue);
620615

621616
for (unsigned int i = 0; i < PISPBE_NUM_NODES; i++)
@@ -703,7 +698,7 @@ static irqreturn_t pispbe_isr(int irq, void *dev)
703698
}
704699

705700
/* check if there's more to do before going to sleep */
706-
pispbe_schedule(pispbe, NULL, can_queue_another);
701+
pispbe_schedule(pispbe, can_queue_another);
707702

708703
return IRQ_HANDLED;
709704
}
@@ -894,7 +889,7 @@ static void pispbe_node_buffer_queue(struct vb2_buffer *buf)
894889
* to do, but only for this client.
895890
*/
896891
if (!pispbe_prepare_job(node_group))
897-
pispbe_schedule(pispbe, node_group, false);
892+
pispbe_schedule(pispbe, false);
898893
}
899894

900895
static int pispbe_node_start_streaming(struct vb2_queue *q, unsigned int count)
@@ -921,7 +916,7 @@ static int pispbe_node_start_streaming(struct vb2_queue *q, unsigned int count)
921916

922917
/* Maybe we're ready to run. */
923918
if (!pispbe_prepare_job(node_group))
924-
pispbe_schedule(pispbe, node_group, false);
919+
pispbe_schedule(pispbe, false);
925920

926921
return 0;
927922

0 commit comments

Comments
 (0)