public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.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: Re: [PATCH 1/1] taging: fbtft: fix memory leak
Date: Tue, 03 Apr 2018 09:20:58 -0700	[thread overview]
Message-ID: <1522772458.11653.51.camel@perches.com> (raw)
In-Reply-To: <1522762386-13990-1-git-send-email-wangxidong_97@163.com>

On Tue, 2018-04-03 at 21:33 +0800, Xidong Wang wrote:
> 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.
[]
> diff --git 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);

What about the

	if (par->gamma.curves && gamma) {
		if (fbtft_gamma_parse_str(par,
			par->gamma.curves, gamma, strlen(gamma)))
			goto alloc_fail;
	}

a little above this?

Presumable then it should goto err_info too.

  reply	other threads:[~2018-04-03 16:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-03 13:33 [PATCH 1/1] taging: fbtft: fix memory leak Xidong Wang
2018-04-03 16:20 ` Joe Perches [this message]
  -- 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=1522772458.11653.51.camel@perches.com \
    --to=joe@perches.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 \
    --cc=wangxidong_97@163.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