linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Yang Zi <2959243019@qq.com>, linux-fbdev@vger.kernel.org
Cc: sh_def@163.com, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fbdev: ssd1307fb: fix NULL pointer dereference on missing match data
Date: Thu, 10 Sep 2026 22:02:43 +0200	[thread overview]
Message-ID: <39c574c0-7890-4a91-bbcb-c5038a758514@gmx.de> (raw)
In-Reply-To: <tencent_93CDCEC8A5EA657378E58B59854679079C0A@qq.com>

On 8/25/26 10:58, Yang Zi wrote:
> device_get_match_data() can return NULL, e.g. when the device is matched
> through the I2C device ID table rather than the OF match table. The
> returned value is stored in par->device_info and later dereferenced when
> initializing par->vcomh, causing a NULL pointer dereference.
> 
> Check the return value right after the assignment and bail out with
> -ENODEV (releasing the already allocated framebuffer) before any
> dereference.
> 
> Signed-off-by: Yang Zi <2959243019@qq.com>

The patch did not apply cleanly. I fixed it up manually and applied it.

Thanks!
Helge

> ---
> diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
> index c4fdecafd856..4d185c754284 100644
> --- a/drivers/video/fbdev/ssd1307fb.c
> +++ b/drivers/video/fbdev/ssd1307fb.c
> @@ -665,6 +665,10 @@ static int ssd1307fb_probe(struct i2c_client *client)
>       spin_lock_init(&par->damage_lock);
>   
>       par->device_info = device_get_match_data(dev);
> +    if (!par->device_info) {
> +        ret = -ENODEV;
> +        goto fb_alloc_error;
> +    }
>   
>       par->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
>       if (IS_ERR(par->reset)) {
> 


      reply	other threads:[~2026-09-10 20:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  8:58 [PATCH] fbdev: ssd1307fb: fix NULL pointer dereference on missing match data Yang Zi
2026-09-10 20:02 ` 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=39c574c0-7890-4a91-bbcb-c5038a758514@gmx.de \
    --to=deller@gmx.de \
    --cc=2959243019@qq.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sh_def@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;
as well as URLs for NNTP newsgroup(s).