Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1332760ybp; Thu, 17 Oct 2019 11:11:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwefAwSUrOVyRtOtO4Ifc7x66gxISGu5Uk8KR6O/R27PFHh12B6oX3R7PC3ff3a39qc3Aov X-Received: by 2002:aa7:ce8c:: with SMTP id y12mr5226850edv.171.1571335889808; Thu, 17 Oct 2019 11:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571335889; cv=none; d=google.com; s=arc-20160816; b=i1i++ax6yO/Gdu1O5imupLWL8BP2njoQQM/lBAyC2Qicm60gKsSYbJBfxa6VNVsZta faFw4nBGNSU0DZAQAusr5PU+9T6nrfkx9aWw7+rnO1w6cF7FWGkhQe+vHKZMnDAC8I2P lORhSqKBCOoRs+LxF5HgD+XK23Ussk7qkyzX+sKSNfHvN7UqjA6qPIT3QBdaf6JuKXrz 9DbFJQX/I1mm+HsIOw9AA3Jal/no/H0tvFBp5DeA049vw+cugyhdjg8MvggybOXP6HTU 4d53ubOsDSklw4uwhY2bNKjtnAIjHZSudOVjDB1CKFMi5/hhfgtONYr4stfaqtWOQbRJ GR2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iZnj6UG4wdZj+2dWNFlH+pPtMXwqCP9S27s2/5lenNE=; b=YF1Ye5z5qNbCAWbi5yHyJCnHKbuOVGZAmRCSmIK6vONsMgMCKmk8yc3y5Ty4sM8Qw+ Auw7Y5mh5rxf2ogu+8Sxys6Cep9uBZ63I/r6B/1qd+M1Y4a02O9DA8WXT+F8TImgIAae CZlrCqK4vg6My3L8gBpQLX84R3snN5b9oOQnvXZ2z7SsY3JcRE9ZwbJDwpkYUAVaS1u1 aDYPeMVv/x5o6oh/puWNijm/AyK66LTgKbW3E9Yro5Blxz6FrX8SKSnh6NdqJdZ1HD4K ZohObb0oh0JHnSeQ4G2gGlxY6Ge7Rjpq0u8QUaAJxUXNzzpLBja/hTbR+w0sBQM5ntwU O9Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MMO22C3v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15si2147587eda.152.2019.10.17.11.11.06; Thu, 17 Oct 2019 11:11:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MMO22C3v; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438613AbfJPV7o (ORCPT + 99 others); Wed, 16 Oct 2019 17:59:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:52626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438255AbfJPV6q (ORCPT ); Wed, 16 Oct 2019 17:58:46 -0400 Received: from localhost (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5D12921925; Wed, 16 Oct 2019 21:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263125; bh=LWgLsoX1gvGw1i0WlasUv7H00ezR1kmu8IDt3Rw9Tqc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMO22C3vrL2NCjHF4a1PDkzz1MWUCBFY+u+7hgu4WbAOsE1jBAnkIEURyHMDW8+IZ 9htgkeUgwWg9nhn4i02qI8bD/+PrXYXOTShQwhHm4Zpf5Wqook0iQY8EaJTl0+4wcA O42kXFWTMFtLGTEMHG+dLDcm2z1DuudSGVos0YKo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Navid Emamdoost , Dan Carpenter Subject: [PATCH 5.3 049/112] Staging: fbtft: fix memory leak in fbtft_framebuffer_alloc Date: Wed, 16 Oct 2019 14:50:41 -0700 Message-Id: <20191016214855.334419989@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214844.038848564@linuxfoundation.org> References: <20191016214844.038848564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Navid Emamdoost commit 5bdea6060618cfcf1459dca137e89aee038ac8b9 upstream. In fbtft_framebuffer_alloc the error handling path should take care of releasing frame buffer after it is allocated via framebuffer_alloc, too. Therefore, in two failure cases the goto destination is changed to address this issue. Fixes: c296d5f9957c ("staging: fbtft: core support") Signed-off-by: Navid Emamdoost Reviewed-by: Dan Carpenter Cc: stable Link: https://lore.kernel.org/r/20190930030949.28615-1-navid.emamdoost@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -714,7 +714,7 @@ struct fb_info *fbtft_framebuffer_alloc( if (par->gamma.curves && gamma) { if (fbtft_gamma_parse_str(par, par->gamma.curves, gamma, strlen(gamma))) - goto alloc_fail; + goto release_framebuf; } /* Transmit buffer */ @@ -731,7 +731,7 @@ struct fb_info *fbtft_framebuffer_alloc( if (txbuflen > 0) { txbuf = devm_kzalloc(par->info->device, txbuflen, GFP_KERNEL); if (!txbuf) - goto alloc_fail; + goto release_framebuf; par->txbuf.buf = txbuf; par->txbuf.len = txbuflen; } @@ -753,6 +753,9 @@ struct fb_info *fbtft_framebuffer_alloc( return info; +release_framebuf: + framebuffer_release(info); + alloc_fail: vfree(vmem);