diff mbox

drm/vmwgfx: Handle vmalloc() failure in vmw_local_fifo_reserve()

Message ID 20170427091208.mpdh2ldnolyusrpx@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter April 27, 2017, 9:12 a.m. UTC
If vmalloc() fails then we need to a bit of cleanup before returning.

Fixes: fb1d9738ca05 ("drm/vmwgfx: Add DRM driver for VMware Virtual GPU")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Sinclair Yeh May 1, 2017, 5:51 p.m. UTC | #1
Thanks Dan!

Reviewed-by: Sinclair Yeh <syeh@vmware.com>

On Thu, Apr 27, 2017 at 12:12:08PM +0300, Dan Carpenter wrote:
> If vmalloc() fails then we need to a bit of cleanup before returning.
> 
> Fixes: fb1d9738ca05 ("drm/vmwgfx: Add DRM driver for VMware Virtual GPU")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
> index b6a0806b06bf..a1c68e6a689e 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
> @@ -368,6 +368,8 @@ static void *vmw_local_fifo_reserve(struct vmw_private *dev_priv,
>  				return fifo_state->static_buffer;
>  			else {
>  				fifo_state->dynamic_buffer = vmalloc(bytes);
> +				if (!fifo_state->dynamic_buffer)
> +					goto out_err;
>  				return fifo_state->dynamic_buffer;
>  			}
>  		}
diff mbox

Patch

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
index b6a0806b06bf..a1c68e6a689e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
@@ -368,6 +368,8 @@  static void *vmw_local_fifo_reserve(struct vmw_private *dev_priv,
 				return fifo_state->static_buffer;
 			else {
 				fifo_state->dynamic_buffer = vmalloc(bytes);
+				if (!fifo_state->dynamic_buffer)
+					goto out_err;
 				return fifo_state->dynamic_buffer;
 			}
 		}