media: intel/ipu6: add csi2 port sanity check in notifier bound
Subsystems (2)
PATCH v2 1/1 media: intel/ipu6: add csi2 port sanity check in notifier bound
From: Bingbu Cao <[email protected]>
Invalid csi2 port will break the isys notifier bound ops as it is trying to access an invalid csi2 sub-device instance based on the port. It will trigger a mc warning, and it will cause the sensor driver to unbound an inexistent isys csi2 and crash. Adding a csi2 port sanity check, return error to avoid such case.
--- drivers/media/pci/intel/ipu6/ipu6-isys.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/media/pci/intel/ipu6/ipu6-isys.c +6 -0
@@ -678,6 +678,12 @@ static int isys_notifier_bound(struct v4l2_async_notifier *notifier, container_of(asc, struct sensor_async_sd, asc);int ret; +if (s_asd->csi2.port >= isys->pdata->ipdata->csi2.nport) { +dev_err (&isys->adev->auxdev.dev,"invalid csi2 port %u\n" , + s_asd->csi2.port); +return -EINVAL ; + } + ret =ipu_bridge_instantiate_vcm (sd->dev);if (ret) {dev_err (&isys->adev->auxdev.dev,"instantiate vcm failed\n" );
Signature · 1 line
2.34.1
Sakari Ailus
maintainerQuoted 9 lines · On Wed, May 29, 2024 at 02:43:21PM +0800, [email protected] wrote:
From: Bingbu Cao <[email protected]>
Invalid csi2 port will break the isys notifier bound ops as it is trying to access an invalid csi2 sub-device instance based on the port. It will trigger a mc warning, and it will cause the sensor driver to unbound an inexistent isys csi2 and crash. Adding a csi2 port sanity check, return error to avoid such case.
Signed-off-by Bingbu Cao <[email protected]>
Thanks, Bingbu!
Both applied, this one got:
Signature · 1 line
Sakari Ailus