From: Xidong Wang <wangxidong_97@163.com>
To: Xidong Wang <wangxidong_97@163.com>,
Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org, Xidong Wang <2711406067@qq.com>
Subject: [PATCH 1/1] taging: fbtft: fix memory leak
Date: Tue, 3 Apr 2018 21:33:06 +0800 [thread overview]
Message-ID: <1522762386-13990-1-git-send-email-wangxidong_97@163.com> (raw)
From: Xidong Wang <2711406067@qq.com>
In function fbtft_framebuffer_alloc(), the memory allocated by
framebuffer_alloc() is not released on the error path that txbuflen > 0
and txbuf, which holds the return value of devm_kzalloc(), is NULL.
This will result in a memory leak bug.
Signed-off-by: Xidong Wang <2711406067@qq.com>
---
drivers/staging/fbtft/fbtft-core.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index 0e36b66..e92771e 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -836,7 +836,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 err_info;
par->txbuf.buf = txbuf;
par->txbuf.len = txbuflen;
}
@@ -872,6 +872,9 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
return info;
+err_info:
+ framebuffer_release(info);
+
alloc_fail:
vfree(vmem);
--
2.7.4
next reply other threads:[~2018-04-03 13:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-03 13:33 Xidong Wang [this message]
2018-04-03 16:20 ` [PATCH 1/1] taging: fbtft: fix memory leak Joe Perches
-- strict thread matches above, loose matches on Subject: below --
2018-04-03 13:14 Xidong Wang
2018-04-03 13:29 ` Greg Kroah-Hartman
2018-04-03 13:52 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1522762386-13990-1-git-send-email-wangxidong_97@163.com \
--to=wangxidong_97@163.com \
--cc=2711406067@qq.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=thomas.petazzoni@free-electrons.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).