OSDN Git Service

media: atomisp: avoid OOPS due to non-existing ref_frames
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 27 May 2020 13:46:54 +0000 (15:46 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 11 Jun 2020 16:15:51 +0000 (18:15 +0200)
stage->args->delay_frames array could point to NULL frames.

What's weird is that we didn't notice this behavior with the
Intel Aero Yocto code.

Handle it, while adding a notice at the code, as this could
be due to some broken pipeline setup.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/pci/isp/kernels/ref/ref_1.0/ia_css_ref.host.c
drivers/staging/media/atomisp/pci/sh_css_sp.c

index 3859474..cbe3836 100644 (file)
@@ -29,10 +29,15 @@ ia_css_ref_config(
 {
        unsigned int elems_a = ISP_VEC_NELEMS, i;
 
-       (void)size;
-       ia_css_dma_configure_from_info(&to->port_b, &from->ref_frames[0]->info);
-       to->width_a_over_b = elems_a / to->port_b.elems;
-       to->dvs_frame_delay = from->dvs_frame_delay;
+       if (from->ref_frames[0]) {
+               ia_css_dma_configure_from_info(&to->port_b, &from->ref_frames[0]->info);
+               to->width_a_over_b = elems_a / to->port_b.elems;
+               to->dvs_frame_delay = from->dvs_frame_delay;
+       } else {
+               to->width_a_over_b = 1;
+               to->dvs_frame_delay = 0;
+               to->port_b.elems = elems_a;
+       }
        for (i = 0; i < MAX_NUM_VIDEO_DELAY_FRAMES; i++) {
                if (from->ref_frames[i]) {
                        to->ref_frame_addr_y[i] = from->ref_frames[i]->data +
index 1ed060d..db543c3 100644 (file)
@@ -839,6 +839,17 @@ configure_isp_from_args(
        ia_css_dvs_configure(binary, &args->out_frame[0]->info);
        ia_css_output_configure(binary, &args->out_frame[0]->info);
        ia_css_raw_configure(pipeline, binary, &args->in_frame->info, &binary->in_frame_info, two_ppc, deinterleaved);
+
+       /*
+        * FIXME: args->delay_frames can be NULL here
+        *
+        * Somehow, the driver at the Intel Atom Yocto tree doesn't seem to
+        * suffer from the same issue.
+        *
+        * Anyway, the function below should now handle a NULL delay_frames
+        * without crashing, but the pipeline should likely be built without
+        * adding it at the first place (or there are a hidden bug somewhere)
+        */
        ia_css_ref_configure(binary, args->delay_frames, pipeline->dvs_frame_delay);
        ia_css_tnr_configure(binary, args->tnr_frames);
        ia_css_bayer_io_config(binary, args);