dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: yuebingkun <yuebingkun@kylinos.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] fbdev: platinumfb: replace strcpy with strscpy
Date: Mon, 17 Aug 2026 03:26:45 +0000	[thread overview]
Message-ID: <20260817032646.66FE91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260817031816.188833-1-yuebingkun@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The return values of `ioremap()` and `ioremap_wt()` are not checked in `platinumfb_probe()`. If these memory mappings fail, the driver will dereference NULL pointers, leading to a kernel panic or memory corruption.
--

--- Patch [1]: [PATCH] fbdev: platinumfb: replace strcpy with strscpy ---
commit 6966c7026a255de8bfc9e604d65d483193521ed1
Author: yuebingkun <yuebingkun@kylinos.cn>

fbdev: platinumfb: replace strcpy with strscpy

strcpy() is deprecated for use on fixed-size buffers. Replace it with
strscpy() to avoid potential buffer overflow issues.

> diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c
> index a08d955d9b439..fa27a3a4f05b2 100644
> --- a/drivers/video/fbdev/platinumfb.c
> +++ b/drivers/video/fbdev/platinumfb.c
> @@ -320,7 +320,7 @@ static void platinum_init_info(struct fb_info *info,
>  	fb_alloc_cmap(&info->cmap, 256, 0);
>  
>  	/* Fill fix common fields */
> -	strcpy(info->fix.id, "platinum");
> +	strscpy(info->fix.id, "platinum", sizeof(info->fix.id));

[Severity: High]
This isn't a bug introduced by this patch, but I noticed there are missing
checks for the return values of memory mapping functions in the same file.

If ioremap() or ioremap_wt() fails during device probe, they return NULL.
This could lead to a NULL pointer dereference in the same function:

drivers/video/fbdev/platinumfb.c:platinumfb_probe() {
	...
	pinfo->frame_buffer = ioremap_wt(pinfo->rsrc_fb.start, 0x400000);
	pinfo->base_frame_buffer = pinfo->frame_buffer;
	...
	pinfo->platinum_regs = ioremap(pinfo->rsrc_reg.start, 0x1000);
	...
	out_be32(&pinfo->platinum_regs->reg[16].r, (unsigned)pinfo->frame_buffer_phys);
	...
	fbuffer = pinfo->base_frame_buffer;
	fbuffer[0x100000] = 0x34;
	...
}

Should the return values of ioremap_wt() and ioremap() be checked before
dereferencing these pointers?

>  	info->fix.mmio_start = pinfo->platinum_regs_phys;
>  	info->fix.mmio_len = 0x1000;
>  	info->fix.type = FB_TYPE_PACKED_PIXELS;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260817031816.188833-1-yuebingkun@kylinos.cn?part=1

  reply	other threads:[~2026-08-17  3:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17  3:18 [PATCH] fbdev: platinumfb: replace strcpy with strscpy yuebingkun
2026-08-17  3:26 ` sashiko-bot [this message]
2026-08-17 14:37 ` David Laight
2026-08-18  0:48   ` yuebingkun
2026-08-18  0:54   ` yuebingkun

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=20260817032646.66FE91F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yuebingkun@kylinos.cn \
    /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