drm/radeon: fix a bogus kfree
authorIlija Hadzic <ihadzic@research.bell-labs.com>
Mon, 7 Jan 2013 23:21:58 +0000 (18:21 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 10 Jan 2013 22:05:36 +0000 (17:05 -0500)
parser->chunks[.].kpage[.] is not always kmalloc-ed
by the parser initialization, so parser_fini should
not try to kfree it if it didn't allocate it.

This patch fixes a kernel oops that can be provoked
in UMS mode.

Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/r600_cs.c

index 03191a56eb443424d35ffbaa84b82ffe96fa1d8a..6858a4068f7bd2fb18309025644d0c2944aa7a50 100644 (file)
@@ -2476,8 +2476,10 @@ static void r600_cs_parser_fini(struct radeon_cs_parser *parser, int error)
        kfree(parser->relocs);
        for (i = 0; i < parser->nchunks; i++) {
                kfree(parser->chunks[i].kdata);
-               kfree(parser->chunks[i].kpage[0]);
-               kfree(parser->chunks[i].kpage[1]);
+               if (parser->rdev && (parser->rdev->flags & RADEON_IS_AGP)) {
+                       kfree(parser->chunks[i].kpage[0]);
+                       kfree(parser->chunks[i].kpage[1]);
+               }
        }
        kfree(parser->chunks);
        kfree(parser->chunks_array);