Skip to contentSkip to conversation

media: staging/imx: Fix NULL deref in find_pipeline_entity()

PATCH In review Steve Longerbeam 3 participants 3 messages Jun 26, 2019 – Jun 27, 2019

Subsystems (4)
lore
Share & tools
lore

Steve Longerbeam

author maintainer
#0 lore raw

PATCH 1/1 media: staging/imx: Fix NULL deref in find_pipeline_entity()

Fix a cut&paste error in find_pipeline_entity(). The start entity must be passed to media_entity_to_video_device() in find_pipeline_entity(), not pad->entity. The pad is only put to use later, after determining the start entity is not the entity being searched for.

Fixes 3ef46bc97ca2 ("media: staging/imx: Improve pipeline searching")
---
 drivers/staging/media/imx/imx-media-utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/imx/imx-media-utils.c +1 -1
index b5b8a3b7730a..6fb88c22ee27 100644
@@ -842,7 +842,7 @@ find_pipeline_entity(struct media_entity *start, u32 grp_id,
 		if (sd->grp_id & grp_id)
 			return &sd->entity;
 	} else if (buftype && is_media_entity_v4l2_video_device(start)) {
-		vfd = media_entity_to_video_device(pad->entity);
+		vfd = media_entity_to_video_device(start);
 		if (buftype == vfd->queue->type)
 			return &vfd->entity;
 	}
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Steve Longerbeam

Fix a cut&paste error in find_pipeline_entity(). The start entity must be passed to media_entity_to_video_device() in find_pipeline_entity(), not pad->entity. The pad is only put to use later, after determining the start entity is not the entity being searched for.

Fixes 3ef46bc97ca2 ("media: staging/imx: Improve pipeline searching")
---
 drivers/staging/media/imx/imx-media-utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/imx/imx-media-utils.c +0 -0
index b5b8a3b7730a..6fb88c22ee27 100644

drivers/staging/media/imx/imx-media-utils.c find_pipeline_entity(struct media_entity *start, u32 grp_id, · line 848

Quoted 8 lines
drivers/staging/media/imx/imx-media-utils.c +1 -1
@@ -842,7 +842,7 @@ find_pipeline_entity(struct media_entity *start, u32 grp_id,
 		if (sd->grp_id & grp_id)
 			return &sd->entity;
 	} else if (buftype && is_media_entity_v4l2_video_device(start)) {
-		vfd = media_entity_to_video_device(pad->entity);
+		vfd = media_entity_to_video_device(start);
 		if (buftype == vfd->queue->type)
 			return &vfd->entity;
 	}

regards
Philipp

#2 lore raw
In reply to Steve Longerbeam
Quoted 18 lines · Steve Longerbeam

Fix a cut&paste error in find_pipeline_entity(). The start entity must be passed to media_entity_to_video_device() in find_pipeline_entity(), not pad->entity. The pad is only put to use later, after determining the start entity is not the entity being searched for.

Fixes 3ef46bc97ca2 ("media: staging/imx: Improve pipeline searching")
---
 drivers/staging/media/imx/imx-media-utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/imx/imx-media-utils.c +0 -0
index b5b8a3b7730a..6fb88c22ee27 100644

drivers/staging/media/imx/imx-media-utils.c find_pipeline_entity(struct media_entity *start, u32 grp_id, · line 845

Quoted 5 lines
drivers/staging/media/imx/imx-media-utils.c +1 -1
@@ -842,7 +842,7 @@ find_pipeline_entity(struct media_entity *start, u32 grp_id,
 		if (sd->grp_id & grp_id)
 			return &sd->entity;
 	} else if (buftype && is_media_entity_v4l2_video_device(start)) {
-		vfd = media_entity_to_video_device(pad->entity);
+		vfd = media_entity_to_video_device(start);

Can we also remove the "pad = NULL" assignment at the start of the function? Otherwise static checkers and new versions of GCC will warn that the assignment isn't used. Plus removing the initialization will prevent bugs like this in the future.

regards,
dan carpenter

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel