From patchwork Mon Sep 30 03:09:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Navid Emamdoost X-Patchwork-Id: 11165969 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6818114DB for ; Mon, 30 Sep 2019 03:10:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E74520863 for ; Mon, 30 Sep 2019 03:10:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hetnKUgs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728853AbfI3DKA (ORCPT ); Sun, 29 Sep 2019 23:10:00 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:35206 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726360AbfI3DKA (ORCPT ); Sun, 29 Sep 2019 23:10:00 -0400 Received: by mail-io1-f66.google.com with SMTP id q10so34394834iop.2; Sun, 29 Sep 2019 20:09:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=JdWTb1V4IhUUMb47mN6yAdg27zy2bK0W+qF3wp30fYo=; b=hetnKUgsD2zSGDpE7xOLnzeBpXHQYJEYYEqnzJSwcvWeNhdWPsdlC6/Pbtswtb+2tg ReMBVDCg9wXGCrev7wYoFfActSDTXjhCrs0vGHKXQNlzmnTvodwpgC8GReVyUTL0cUH6 jPTCtsx6gOP9iFcUzUyy2V77UQAkJPNLpN/9ZFmSxBsi6rCppsNdoC3ciTBBpVHYGV8Z Myyx7ePbg+RWklM9om4+N+eOelSbT4G5BFWA9tPOKtxcimECtmLWNhuAU4sZY3PA7GSi 2E2BiHEuooVd+tzXxgBWNKKeiMaqgI0bZFAkItESu2W1K44vsybFpfUDwksMtW2XWFcq p/mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JdWTb1V4IhUUMb47mN6yAdg27zy2bK0W+qF3wp30fYo=; b=qTA1OPG01dk3OU3azeHvSXJuynJuWzybyqS87C0xIBx9iOw1L7ccEs6gKcwAMC+2fR rdFfSav6f2CdYqr33H2BSDB7zCWtUf1gq/xatdozyZ79oixLhBbaX/YF56lYqg6qLgvs gSEc7bhLKfwYPi1shq+GBRZz6b8F8XLB4yCiGGOTsAmnFQXN6sP31bukhioFskm8TdXd AhRmkgLaobATUQG79w4oPjMkdFFe97y0RsMV7JX965F1t2pAPiphN/J59GLHxhLnCK2n 5A/vMi22vYjsM4nXYUtDUv1DcNj9gy5xojhUK95nrfLzVYVb07/p77EojqhGCA4yhimI 2q4w== X-Gm-Message-State: APjAAAWGEH1bitG6HOuvyYajlEkFPJuF99oGanczrPuP1hmHFBpKZBEa CVczJtBMYkbExgcmb6xF9UU= X-Google-Smtp-Source: APXvYqw9S4icJAA3Iim6bEKEOhPYCZHJFDUjRkHAKLayY1qZ/8t7tcsSVHOGYMUZdwQB5yUeCahPEQ== X-Received: by 2002:a5d:9349:: with SMTP id i9mr3190833ioo.101.1569812999347; Sun, 29 Sep 2019 20:09:59 -0700 (PDT) Received: from cs-dulles.cs.umn.edu (cs-dulles.cs.umn.edu. [128.101.35.54]) by smtp.googlemail.com with ESMTPSA id r22sm5444086ilb.85.2019.09.29.20.09.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Sep 2019 20:09:58 -0700 (PDT) From: Navid Emamdoost Cc: emamd001@umn.edu, kjlu@umn.edu, smccaman@umn.edu, Navid Emamdoost , Greg Kroah-Hartman , Nicolas Saenz Julienne , Bhanusree Pola , Phil Reid , Sam Ravnborg , Daniel Vetter , =?utf-8?q?Jan_Sebastian_G=C3=B6tte?= , Nishad Kamdar , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] Staging: fbtft: fix memory leak in fbtft_framebuffer_alloc Date: Sun, 29 Sep 2019 22:09:45 -0500 Message-Id: <20190930030949.28615-1-navid.emamdoost@gmail.com> X-Mailer: git-send-email 2.17.1 To: unlisted-recipients:; (no To-header on input) Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org 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 --- drivers/staging/fbtft/fbtft-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index cf5700a2ea66..a0a67aa517f0 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -714,7 +714,7 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display, 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(struct fbtft_display *display, 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(struct fbtft_display *display, return info; +release_framebuf: + framebuffer_release(info); + alloc_fail: vfree(vmem);