Skip to contentSkip to conversation

drm/radeon: fix a bogus kfree

PATCH New Shuah Khan 1 participant 1 message Jan 17, 2013

Subsystems (2)
lore
Share & tools
lore

Shuah Khan

author
#0 lore raw

PATCH 1/1 drm/radeon: fix a bogus kfree

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.

Upstream commit-id: a6b7e1a02b77ab8fe8775d20a88c53d8ba55482e Tested on stable 3.7

---
 drivers/gpu/drm/radeon/r600_cs.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/r600_cs.c +4 -2
index 03191a5..6858a40 100644
@@ -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);
Signature · 1 line
1.7.9.5