Skip to contentSkip to conversation

media: nxp: imx8-isi: Check whether crossbar pad is non-NULL before access

git:media_stage/master Hans Verkuil 1 participant 1 message Feb 5, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

This is an automatic generated email to let you know that the following patch were queued:

Subject: media: nxp: imx8-isi: Check whether crossbar pad is non-NULL before access
Author:  Marek Vasut <[email protected]>
Date:    Fri Dec 1 16:06:04 2023 +0100

When translating source to sink streams in the crossbar subdev, the driver tries to locate the remote subdev connected to the sink pad. The remote pad may be NULL, if userspace tries to enable a stream that ends at an unconnected crossbar sink. When that occurs, the driver dereferences the NULL pad, leading to a crash.

Prevent the crash by checking if the pad is NULL before using it, and return an error if it is.

 drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

---

drivers/media/platform/nxp/imx8-isi/imx8-isi-crossbar.c +7 -1
index 575f17337388..1bb1334ec6f2 100644
@@ -160,8 +160,14 @@ mxc_isi_crossbar_xlate_streams(struct mxc_isi_crossbar *xbar,
 	}
 
 	pad = media_pad_remote_pad_first(&xbar->pads[sink_pad]);
-	sd = media_entity_to_v4l2_subdev(pad->entity);
+	if (!pad) {
+		dev_dbg(xbar->isi->dev,
+			"no pad connected to crossbar input %u\n",
+			sink_pad);
+		return ERR_PTR(-EPIPE);
+	}
 
+	sd = media_entity_to_v4l2_subdev(pad->entity);
 	if (!sd) {
 		dev_dbg(xbar->isi->dev,
 			"no entity connected to crossbar input %u\n",