Skip to contentSkip to conversation

v4l: mx3_camera: fix NULL pointer dereference if debug output enabled

PATCH In review Anatolij Gustschin 2 participants 3 messages Jan 31, 2011 – Feb 2, 2011 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 v4l: mx3_camera: fix NULL pointer dereference if debug output enabled

Running with enabled debug output in the mx3_camera driver results in a kernel crash:
...
mx3-camera mx3-camera.0: Providing format Bayer BGGR (sRGB) 8 bit using code 11

Unable to handle kernel NULL pointer dereference at virtual address 00000004

...

Fix it by incrementing 'xlate' after usage.

---
 drivers/media/video/mx3_camera.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/media/video/mx3_camera.c +1 -1
index b9cb4a4..7bcaaf7 100644
@@ -734,9 +734,9 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id
 	if (xlate) {
 		xlate->host_fmt	= fmt;
 		xlate->code	= code;
-		xlate++;
 		dev_dbg(dev, "Providing format %x in pass-through mode\n",
 			xlate->host_fmt->fourcc);
+		xlate++;
 	}
 
 	return formats;
Signature · 1 line
1.7.1
#1 lore raw
Quoted 19 lines · Anatolij Gustschin

Running with enabled debug output in the mx3_camera driver results in a kernel crash:
...
mx3-camera mx3-camera.0: Providing format Bayer BGGR (sRGB) 8 bit using code 11

Unable to handle kernel NULL pointer dereference at virtual address 00000004

...

Fix it by incrementing 'xlate' after usage.

---
 drivers/media/video/mx3_camera.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/media/video/mx3_camera.c +0 -0
index b9cb4a4..7bcaaf7 100644

drivers/media/video/mx3_camera.c static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id · line 739

Quoted 7 lines
drivers/media/video/mx3_camera.c +1 -1
@@ -734,9 +734,9 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id
 	if (xlate) {
 		xlate->host_fmt	= fmt;
 		xlate->code	= code;
-		xlate++;
 		dev_dbg(dev, "Providing format %x in pass-through mode\n",
 			xlate->host_fmt->fourcc);
+		xlate++;

Let's take an even easier path:

- xlate->host_fmt->fourcc);
+ fmt->fourcc);

Quoted 5 lines
drivers/media/video/mx3_camera.c +0 -0
 	}
 
 	return formats;
Signature · 1 line
1.7.1

Thanks
Guennadi
---
Guennadi Liakhovetski

#2 lore raw
Quoted 31 lines · Guennadi Liakhovetski
Quoted 19 lines · Anatolij Gustschin

Running with enabled debug output in the mx3_camera driver results in a kernel crash:
...
mx3-camera mx3-camera.0: Providing format Bayer BGGR (sRGB) 8 bit using code 11

Unable to handle kernel NULL pointer dereference at virtual address 00000004

...

Fix it by incrementing 'xlate' after usage.

---
 drivers/media/video/mx3_camera.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/media/video/mx3_camera.c +0 -0
index b9cb4a4..7bcaaf7 100644

drivers/media/video/mx3_camera.c static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id · line 739

Quoted 7 lines
drivers/media/video/mx3_camera.c +1 -1
@@ -734,9 +734,9 @@ static int mx3_camera_get_formats(struct soc_camera_device *icd, unsigned int id
 	if (xlate) {
 		xlate->host_fmt	= fmt;
 		xlate->code	= code;
-		xlate++;
 		dev_dbg(dev, "Providing format %x in pass-through mode\n",
 			xlate->host_fmt->fourcc);
+		xlate++;

Let's take an even easier path:

Review

Quoted 2 lines
(quoted diff) +1 -1
-			xlate->host_fmt->fourcc);
+			fmt->fourcc);

Ok, sorry, forget it - this entire patch is superseded by another one.

Guennadi

Quoted 4 lines
Quoted 4 lines
drivers/media/video/mx3_camera.c +0 -0
 	}
 
Quoted 9 lines
Quoted 3 lines
drivers/media/video/mx3_camera.c +0 -0
 	return formats;
Signature · 1 line
1.7.1

Thanks
Guennadi
---
Guennadi Liakhovetski

---
Guennadi Liakhovetski