diff mbox

[2/7] display: prevent a NULL pointer dereference in intel_set_scanout_pixmap

Message ID 1455294689-29249-3-git-send-email-martin.peres@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Martin Peres Feb. 12, 2016, 4:31 p.m. UTC
Caught by Klockwork.

Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
---
 src/uxa/intel_display.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Chris Wilson Feb. 12, 2016, 5:34 p.m. UTC | #1
On Fri, Feb 12, 2016 at 06:31:24PM +0200, Martin Peres wrote:
> Caught by Klockwork.
> 
> Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
> ---
>  src/uxa/intel_display.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
> index 8bf0184..44744a5 100644
> --- a/src/uxa/intel_display.c
> +++ b/src/uxa/intel_display.c
> @@ -688,6 +688,11 @@ intel_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
>  	}
>  
>  	bo = intel_get_pixmap_bo(ppix);
> +	if (!bo) {
> +		ErrorF("pixmap is not backed by a BO\n");

Just return FALSE.

> +		return FALSE;
> +	}
> +
>  	if (intel->front_buffer) {
>  		ErrorF("have front buffer\n");

And let's add the return here as well instead of the ErrorF

If the caller does make the mistake of passing in an invalid Pixmap,
what's the likelihood of them checking the return? ;)
-Chris
diff mbox

Patch

diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
index 8bf0184..44744a5 100644
--- a/src/uxa/intel_display.c
+++ b/src/uxa/intel_display.c
@@ -688,6 +688,11 @@  intel_set_scanout_pixmap(xf86CrtcPtr crtc, PixmapPtr ppix)
 	}
 
 	bo = intel_get_pixmap_bo(ppix);
+	if (!bo) {
+		ErrorF("pixmap is not backed by a BO\n");
+		return FALSE;
+	}
+
 	if (intel->front_buffer) {
 		ErrorF("have front buffer\n");
 	}