[ 01/58] drm/nouveau/vm: fix memory corruption when pgt allocation fails

From: Greg Kroah-Hartman
Date: Mon Feb 25 2013 - 17:34:05 EST


3.7-stable review patch. If anyone has any objections, please let me know.

------------------

From: Marcin Slusarz <marcin.slusarz@xxxxxxxxx>

commit cfd376b6bfccf33782a0748a9c70f7f752f8b869 upstream.

If we return freed vm, nouveau_drm_open will happily call nouveau_cli_destroy,
which will try to free it again.

Reported-by: Peter Hurley <peter@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Marcin Slusarz <marcin.slusarz@xxxxxxxxx>
Signed-off-by: Ben Skeggs <bskeggs@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
drivers/gpu/drm/nouveau/core/subdev/vm/base.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
+++ b/drivers/gpu/drm/nouveau/core/subdev/vm/base.c
@@ -352,7 +352,7 @@ nouveau_vm_create(struct nouveau_vmmgr *
u64 mm_length = (offset + length) - mm_offset;
int ret;

- vm = *pvm = kzalloc(sizeof(*vm), GFP_KERNEL);
+ vm = kzalloc(sizeof(*vm), GFP_KERNEL);
if (!vm)
return -ENOMEM;

@@ -376,6 +376,8 @@ nouveau_vm_create(struct nouveau_vmmgr *
return ret;
}

+ *pvm = vm;
+
return 0;
}



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/