Linux Framebuffer Layer development
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Abdun Nihaal <nihaal@cse.iitm.ac.in>
Cc: niederp@physik.uni-kl.de, maxime.ripard@free-electrons.com,
	tomi.valkeinen@ti.com, linux-fbdev@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fbdev: ssd1307fb: fix potential page leak in ssd1307fb_probe()
Date: Tue, 2 Dec 2025 20:49:01 +0100	[thread overview]
Message-ID: <cd0696c4-151c-4379-b718-d963d182a060@gmx.de> (raw)
In-Reply-To: <20251202191225.111661-1-nihaal@cse.iitm.ac.in>

On 12/2/25 20:12, Abdun Nihaal wrote:
> The page allocated for vmem using __get_free_pages() is not freed on the
> error paths after it. Fix that by adding a corresponding __free_pages()
> call to the error path.
> 
> Fixes: facd94bc458a ("fbdev: ssd1307fb: Allocate page aligned video memory.")
> Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
> ---
> Compile tested only. Not tested on hardware.
> 
>   drivers/video/fbdev/ssd1307fb.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
> index aa6cc0a8151a..66da8a1a0941 100644
> --- a/drivers/video/fbdev/ssd1307fb.c
> +++ b/drivers/video/fbdev/ssd1307fb.c
> @@ -680,7 +680,7 @@ static int ssd1307fb_probe(struct i2c_client *client)
>   	if (!ssd1307fb_defio) {
>   		dev_err(dev, "Couldn't allocate deferred io.\n");
>   		ret = -ENOMEM;
> -		goto fb_alloc_error;
> +		goto fb_defio_error;

this goto jumps over the assignment of info->fix.smem_start, so...
...

>   	}
>   
>   	ssd1307fb_defio->delay = HZ / refreshrate;
> @@ -757,6 +757,8 @@ static int ssd1307fb_probe(struct i2c_client *client)
>   		regulator_disable(par->vbat_reg);
>   reset_oled_error:
>   	fb_deferred_io_cleanup(info);
> +fb_defio_error:
> +	__free_pages(__va(info->fix.smem_start), get_order(info->fix.smem_len));

freeing info->fix.smem_start is wrong here as it was not initialized
to the value of vmem.

Please rework the patch.

Helge


      reply	other threads:[~2025-12-02 19:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-02 19:12 [PATCH] fbdev: ssd1307fb: fix potential page leak in ssd1307fb_probe() Abdun Nihaal
2025-12-02 19:49 ` Helge Deller [this message]

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=cd0696c4-151c-4379-b718-d963d182a060@gmx.de \
    --to=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxime.ripard@free-electrons.com \
    --cc=niederp@physik.uni-kl.de \
    --cc=nihaal@cse.iitm.ac.in \
    --cc=tomi.valkeinen@ti.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