aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2012-10-25 09:56:00 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-10-25 12:42:17 -0400
commit8163ec0b2648c2f7e84edb969dde537ec45f1666 (patch)
tree36cc2ecf1e35f96703db909e8c4279167fa9a3da
parentafd7348c60b4f5d3d4d041aa0c29a6258a476b89 (diff)
[media] s5p-fimc: Fix potential NULL pointer dereference
'fimc' was being dereferenced before the NULL check. Moved it to after the check. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-mdevice.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index a55370219a96..38ea4d143a49 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -343,13 +343,14 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
343static int fimc_register_callback(struct device *dev, void *p) 343static int fimc_register_callback(struct device *dev, void *p)
344{ 344{
345 struct fimc_dev *fimc = dev_get_drvdata(dev); 345 struct fimc_dev *fimc = dev_get_drvdata(dev);
346 struct v4l2_subdev *sd = &fimc->vid_cap.subdev; 346 struct v4l2_subdev *sd;
347 struct fimc_md *fmd = p; 347 struct fimc_md *fmd = p;
348 int ret; 348 int ret;
349 349
350 if (fimc == NULL || fimc->id >= FIMC_MAX_DEVS) 350 if (fimc == NULL || fimc->id >= FIMC_MAX_DEVS)
351 return 0; 351 return 0;
352 352
353 sd = &fimc->vid_cap.subdev;
353 sd->grp_id = FIMC_GROUP_ID; 354 sd->grp_id = FIMC_GROUP_ID;
354 355
355 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); 356 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd);
@@ -367,16 +368,15 @@ static int fimc_register_callback(struct device *dev, void *p)
367static int fimc_lite_register_callback(struct device *dev, void *p) 368static int fimc_lite_register_callback(struct device *dev, void *p)
368{ 369{
369 struct fimc_lite *fimc = dev_get_drvdata(dev); 370 struct fimc_lite *fimc = dev_get_drvdata(dev);
370 struct v4l2_subdev *sd = &fimc->subdev;
371 struct fimc_md *fmd = p; 371 struct fimc_md *fmd = p;
372 int ret; 372 int ret;
373 373
374 if (fimc == NULL || fimc->index >= FIMC_LITE_MAX_DEVS) 374 if (fimc == NULL || fimc->index >= FIMC_LITE_MAX_DEVS)
375 return 0; 375 return 0;
376 376
377 sd->grp_id = FLITE_GROUP_ID; 377 fimc->subdev.grp_id = FLITE_GROUP_ID;
378 378
379 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); 379 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, &fimc->subdev);
380 if (ret) { 380 if (ret) {
381 v4l2_err(&fmd->v4l2_dev, 381 v4l2_err(&fmd->v4l2_dev,
382 "Failed to register FIMC-LITE.%d (%d)\n", 382 "Failed to register FIMC-LITE.%d (%d)\n",