mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm, video: fix use-before-NULL-check
@ 2010-08-27 21:07 Kees Cook
  2010-08-30 16:31 ` Jesse Barnes
  0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2010-08-27 21:07 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dave Airlie, Jesse Barnes, Clemens Ladisch,
	Mauro Carvalho Chehab, Devin Heitmueller, Laurent Pinchart,
	Hans Verkuil, dri-devel, linux-media

Fix potential crashes due to use-before-NULL situations.

Signed-off-by: Kees Cook <kees.cook@canonical.com>
---
 drivers/gpu/drm/drm_fb_helper.c           |    3 ++-
 drivers/media/video/em28xx/em28xx-video.c |    3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index de82e20..8dd7e6f 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -94,10 +94,11 @@ static bool drm_fb_helper_connector_parse_command_line(struct drm_fb_helper_conn
 	int i;
 	enum drm_connector_force force = DRM_FORCE_UNSPECIFIED;
 	struct drm_fb_helper_cmdline_mode *cmdline_mode;
-	struct drm_connector *connector = fb_helper_conn->connector;
+	struct drm_connector *connector;
 
 	if (!fb_helper_conn)
 		return false;
+	connector = fb_helper_conn->connector;
 
 	cmdline_mode = &fb_helper_conn->cmdline_mode;
 	if (!mode_option)
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 7b9ec6e..95a4b60 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -277,12 +277,13 @@ static void em28xx_copy_vbi(struct em28xx *dev,
 {
 	void *startwrite, *startread;
 	int  offset;
-	int bytesperline = dev->vbi_width;
+	int bytesperline;
 
 	if (dev == NULL) {
 		em28xx_isocdbg("dev is null\n");
 		return;
 	}
+	bytesperline = dev->vbi_width;
 
 	if (dma_q == NULL) {
 		em28xx_isocdbg("dma_q is null\n");
-- 
1.7.1


-- 
Kees Cook
Ubuntu Security Team

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm, video: fix use-before-NULL-check
  2010-08-27 21:07 [PATCH] drm, video: fix use-before-NULL-check Kees Cook
@ 2010-08-30 16:31 ` Jesse Barnes
  0 siblings, 0 replies; 2+ messages in thread
From: Jesse Barnes @ 2010-08-30 16:31 UTC (permalink / raw)
  To: Kees Cook
  Cc: linux-kernel, Dave Airlie, Clemens Ladisch,
	Mauro Carvalho Chehab, Devin Heitmueller, Laurent Pinchart,
	Hans Verkuil, dri-devel, linux-media

On Fri, 27 Aug 2010 14:07:19 -0700
Kees Cook <kees.cook@canonical.com> wrote:

> Fix potential crashes due to use-before-NULL situations.
> 
> Signed-off-by: Kees Cook <kees.cook@canonical.com>
> ---
>  drivers/gpu/drm/drm_fb_helper.c           |    3 ++-
>  drivers/media/video/em28xx/em28xx-video.c |    3 ++-
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
> index de82e20..8dd7e6f 100644
> --- a/drivers/gpu/drm/drm_fb_helper.c
> +++ b/drivers/gpu/drm/drm_fb_helper.c
> @@ -94,10 +94,11 @@ static bool drm_fb_helper_connector_parse_command_line(struct drm_fb_helper_conn
>  	int i;
>  	enum drm_connector_force force = DRM_FORCE_UNSPECIFIED;
>  	struct drm_fb_helper_cmdline_mode *cmdline_mode;
> -	struct drm_connector *connector = fb_helper_conn->connector;
> +	struct drm_connector *connector;
>  
>  	if (!fb_helper_conn)
>  		return false;
> +	connector = fb_helper_conn->connector;
>  
>  	cmdline_mode = &fb_helper_conn->cmdline_mode;
>  	if (!mode_option)
> diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
> index 7b9ec6e..95a4b60 100644
> --- a/drivers/media/video/em28xx/em28xx-video.c
> +++ b/drivers/media/video/em28xx/em28xx-video.c
> @@ -277,12 +277,13 @@ static void em28xx_copy_vbi(struct em28xx *dev,
>  {
>  	void *startwrite, *startread;
>  	int  offset;
> -	int bytesperline = dev->vbi_width;
> +	int bytesperline;
>  
>  	if (dev == NULL) {
>  		em28xx_isocdbg("dev is null\n");
>  		return;
>  	}
> +	bytesperline = dev->vbi_width;
>  
>  	if (dma_q == NULL) {
>  		em28xx_isocdbg("dma_q is null\n");

Look fine to me.

Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>


-- 
Jesse Barnes, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-30 16:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-27 21:07 [PATCH] drm, video: fix use-before-NULL-check Kees Cook
2010-08-30 16:31 ` Jesse Barnes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome