media: exynos4-is: Fix nullptr when no CSIS device present
[linux-2.6-microblaze.git] / drivers / media / platform / exynos4-is / media-dev.c
index ae74d8f..aae584f 100644 (file)
@@ -290,11 +290,26 @@ static int __fimc_pipeline_s_stream(struct exynos_media_pipeline *ep, bool on)
                { IDX_CSIS, IDX_FLITE, IDX_FIMC, IDX_SENSOR, IDX_IS_ISP },
        };
        struct fimc_pipeline *p = to_fimc_pipeline(ep);
-       struct fimc_md *fmd = entity_to_fimc_mdev(&p->subdevs[IDX_CSIS]->entity);
        enum fimc_subdev_index sd_id;
        int i, ret = 0;
 
        if (p->subdevs[IDX_SENSOR] == NULL) {
+               struct fimc_md *fmd;
+               struct v4l2_subdev *sd = p->subdevs[IDX_CSIS];
+
+               if (!sd)
+                       sd = p->subdevs[IDX_FIMC];
+
+               if (!sd) {
+                       /*
+                        * If neither CSIS nor FIMC was set up,
+                        * it's impossible to have any sensors
+                        */
+                       return -ENODEV;
+               }
+
+               fmd = entity_to_fimc_mdev(&sd->entity);
+
                if (!fmd->user_subdev_api) {
                        /*
                         * Sensor must be already discovered if we