Skip to contentSkip to conversation

soc_camera: soc_camera_pdrv_probe: fix potential NULL pointer dereference

PATCH In review Wang YanQing 2 participants 2 messages Sep 16, 2015 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 soc_camera: soc_camera_pdrv_probe: fix potential NULL pointer dereference

Move dereference of sdesc after NULL pointer checker.

---
 drivers/media/platform/soc_camera/soc_camera.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/soc_camera/soc_camera.c +2 -1
index 9087fed..53b153d 100644
@@ -2187,13 +2187,14 @@ static int soc_camera_video_start(struct soc_camera_device *icd)
 static int soc_camera_pdrv_probe(struct platform_device *pdev)
 {
 	struct soc_camera_desc *sdesc = pdev->dev.platform_data;
-	struct soc_camera_subdev_desc *ssdd = &sdesc->subdev_desc;
+	struct soc_camera_subdev_desc *ssdd;
 	struct soc_camera_device *icd;
 	int ret;
 
 	if (!sdesc)
 		return -EINVAL;
 
+	ssdd = &sdesc->subdev_desc;
 	icd = devm_kzalloc(&pdev->dev, sizeof(*icd), GFP_KERNEL);
 	if (!icd)
 		return -ENOMEM;
Signature · 1 line
1.8.5.6.2.g3d8a54e.dirty
#1 lore raw
Quoted 12 lines · Wang YanQing

Move dereference of sdesc after NULL pointer checker.

---
 drivers/media/platform/soc_camera/soc_camera.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/soc_camera/soc_camera.c +0 -0
index 9087fed..53b153d 100644

drivers/media/platform/soc_camera/soc_camera.c static int soc_camera_video_start(struct soc_camera_device *icd) · line 2190

Quoted 5 lines
drivers/media/platform/soc_camera/soc_camera.c +1 -1
@@ -2187,13 +2187,14 @@ static int soc_camera_video_start(struct soc_camera_device *icd)
 static int soc_camera_pdrv_probe(struct platform_device *pdev)
 {
 	struct soc_camera_desc *sdesc = pdev->dev.platform_data;
-	struct soc_camera_subdev_desc *ssdd = &sdesc->subdev_desc;
+	struct soc_camera_subdev_desc *ssdd;

NAK. This isn't a dereference. This is just an address calculation.

Thanks
Guennadi

Quoted 13 lines
drivers/media/platform/soc_camera/soc_camera.c +1 -0
 	struct soc_camera_device *icd;
 	int ret;
 
 	if (!sdesc)
 		return -EINVAL;
 
+	ssdd = &sdesc->subdev_desc;
 	icd = devm_kzalloc(&pdev->dev, sizeof(*icd), GFP_KERNEL);
 	if (!icd)
 		return -ENOMEM;
Signature · 1 line
1.8.5.6.2.g3d8a54e.dirty