diff mbox

drm/gk20a/fb: fix NULL dereference

Message ID 1399622268-16940-1-git-send-email-acourbot@nvidia.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alexandre Courbot May 9, 2014, 7:57 a.m. UTC
gk20a_ram_put() can be called with a NULL nouveau_mem in case of error.
Handle that case the way is it done in other RAM drivers.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
---
 drivers/gpu/drm/nouveau/core/subdev/fb/ramgk20a.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Ben Skeggs May 9, 2014, 11:49 p.m. UTC | #1
On Fri, May 9, 2014 at 5:57 PM, Alexandre Courbot <acourbot@nvidia.com> wrote:
> gk20a_ram_put() can be called with a NULL nouveau_mem in case of error.
> Handle that case the way is it done in other RAM drivers.
Got it, thanks!

>
> Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
> ---
>  drivers/gpu/drm/nouveau/core/subdev/fb/ramgk20a.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/ramgk20a.c b/drivers/gpu/drm/nouveau/core/subdev/fb/ramgk20a.c
> index 403c88f07b99..7effd1a63458 100644
> --- a/drivers/gpu/drm/nouveau/core/subdev/fb/ramgk20a.c
> +++ b/drivers/gpu/drm/nouveau/core/subdev/fb/ramgk20a.c
> @@ -36,6 +36,8 @@ gk20a_ram_put(struct nouveau_fb *pfb, struct nouveau_mem **pmem)
>         int i;
>
>         *pmem = NULL;
> +       if (unlikely(mem == NULL))
> +               return;
>
>         for (i = 0; i < mem->size; i++) {
>                 struct page *page;
> --
> 1.9.2
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/nouveau
diff mbox

Patch

diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/ramgk20a.c b/drivers/gpu/drm/nouveau/core/subdev/fb/ramgk20a.c
index 403c88f07b99..7effd1a63458 100644
--- a/drivers/gpu/drm/nouveau/core/subdev/fb/ramgk20a.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/fb/ramgk20a.c
@@ -36,6 +36,8 @@  gk20a_ram_put(struct nouveau_fb *pfb, struct nouveau_mem **pmem)
 	int i;
 
 	*pmem = NULL;
+	if (unlikely(mem == NULL))
+		return;
 
 	for (i = 0; i < mem->size; i++) {
 		struct page *page;