From patchwork Fri Jul 20 18:47:55 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesper Juhl X-Patchwork-Id: 1222151 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 09E1C3FD48 for ; Fri, 20 Jul 2012 18:48:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E60F2A119D for ; Fri, 20 Jul 2012 11:48:06 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from swampdragon.chaosbits.net (1010ds2-suoe.0.fullrate.dk [90.184.90.115]) by gabe.freedesktop.org (Postfix) with ESMTP id 6A4D29EE9C for ; Fri, 20 Jul 2012 11:47:56 -0700 (PDT) Received: by swampdragon.chaosbits.net (Postfix, from userid 1000) id 9B0C99403D; Fri, 20 Jul 2012 20:47:55 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by swampdragon.chaosbits.net (Postfix) with ESMTP id 98ECF9403B; Fri, 20 Jul 2012 20:47:55 +0200 (CEST) Date: Fri, 20 Jul 2012 20:47:55 +0200 (CEST) From: Jesper Juhl To: David Airlie Subject: [PATCH] drm, cirrus_fbdev: Fix leak in cirrusfb_create() Message-ID: User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Cc: Dave Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org We have this code: ... sysram = vmalloc(size); if (!sysram) return -ENOMEM; info = framebuffer_alloc(0, device); if (info == NULL) return -ENOMEM; ... If the vmalloc() call succeeds but the framebuffer_alloc() call subsequently fails then we'll leak the memory allocated for 'sysram' with vmalloc(). Signed-off-by: Jesper Juhl --- drivers/gpu/drm/cirrus/cirrus_fbdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c index 9a276a5..cdaa270 100644 --- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c +++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c @@ -155,8 +155,10 @@ static int cirrusfb_create(struct cirrus_fbdev *gfbdev, return -ENOMEM; info = framebuffer_alloc(0, device); - if (info == NULL) + if (!info) { + vfree(sysram); return -ENOMEM; + } info->par = gfbdev;