From: Enrico Scholz <enrico.scholz@xxxxxxxxxxxxxxxxx> mbus_code_to_bus_cfg() can fail on unknown mbus codes; pass back the error to the caller. Signed-off-by: Enrico Scholz <enrico.scholz@xxxxxxxxxxxxxxxxx> Signed-off-by: Jan Luebbe <jlu@xxxxxxxxxxxxxx> --- drivers/gpu/ipu-v3/ipu-csi.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c index caa05b0702e1..39c3aabb6d17 100644 --- a/drivers/gpu/ipu-v3/ipu-csi.c +++ b/drivers/gpu/ipu-v3/ipu-csi.c @@ -318,13 +318,17 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code) /* * Fill a CSI bus config struct from mbus_config and mbus_framefmt. */ -static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg, +static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg, struct v4l2_mbus_config *mbus_cfg, struct v4l2_mbus_framefmt *mbus_fmt) { + int rc; + memset(csicfg, 0, sizeof(*csicfg)); - mbus_code_to_bus_cfg(csicfg, mbus_fmt->code); + rc = mbus_code_to_bus_cfg(csicfg, mbus_fmt->code); + if (rc < 0) + return rc; switch (mbus_cfg->type) { case V4L2_MBUS_PARALLEL: @@ -355,6 +359,8 @@ static void fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg, /* will never get here, keep compiler quiet */ break; } + + return 0; } int ipu_csi_init_interface(struct ipu_csi *csi, @@ -364,8 +370,11 @@ int ipu_csi_init_interface(struct ipu_csi *csi, struct ipu_csi_bus_config cfg; unsigned long flags; u32 width, height, data = 0; + int rc; - fill_csi_bus_cfg(&cfg, mbus_cfg, mbus_fmt); + rc = fill_csi_bus_cfg(&cfg, mbus_cfg, mbus_fmt); + if (rc < 0) + return rc; /* set default sensor frame width and height */ width = mbus_fmt->width; @@ -586,11 +595,14 @@ int ipu_csi_set_mipi_datatype(struct ipu_csi *csi, u32 vc, struct ipu_csi_bus_config cfg; unsigned long flags; u32 temp; + int rc; if (vc > 3) return -EINVAL; - mbus_code_to_bus_cfg(&cfg, mbus_fmt->code); + rc = mbus_code_to_bus_cfg(&cfg, mbus_fmt->code); + if (rc < 0) + return rc; spin_lock_irqsave(&csi->lock, flags); -- 2.17.0 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel