dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: fbtft: name the no-op endian modifier in define_fbtft_write_reg()
@ 2026-08-30 16:15 anshika
  2026-08-31  5:47 ` Greg Kroah-Hartman
  2026-08-31  7:07 ` sashiko-bot
  0 siblings, 2 replies; 3+ messages in thread
From: anshika @ 2026-08-30 16:15 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Greg Kroah-Hartman, Dan Carpenter, dri-devel, linux-fbdev,
	linux-staging, anshika

Two of the three define_fbtft_write_reg() instantiations pass an empty
modifier argument, which checkpatch flags as a fragile empty macro
argument. Give the no-op case an explicit name instead of leaving it
blank.

No functional change.

Link: https://lkml.iu.edu/hypermail/linux/kernel/2602.0/01917.html

Signed-off-by: anshika <anshikajain196872@gmail.com>
---
 drivers/staging/fbtft/fbtft-bus.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c
index 30e436ff1..e03aa251c 100644
--- a/drivers/staging/fbtft/fbtft-bus.c
+++ b/drivers/staging/fbtft/fbtft-bus.c
@@ -10,6 +10,7 @@
  *   void (*write_reg)(struct fbtft_par *par, int len, ...);
  *
  *****************************************************************************/
+#define cpu_to_cpu_endian(x) (x)
 
 #define define_fbtft_write_reg(func, buffer_type, data_type, modifier)        \
 void func(struct fbtft_par *par, int len, ...)                                \
@@ -62,9 +63,9 @@ out:									      \
 }                                                                             \
 EXPORT_SYMBOL(func);
 
-define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, )
+define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, cpu_to_cpu_endian)
 define_fbtft_write_reg(fbtft_write_reg16_bus8, __be16, u16, cpu_to_be16)
-define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, )
+define_fbtft_write_reg(fbtft_write_reg16_bus16, u16, u16, cpu_to_cpu_endian)
 
 void fbtft_write_reg8_bus9(struct fbtft_par *par, int len, ...)
 {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: fbtft: name the no-op endian modifier in define_fbtft_write_reg()
  2026-08-30 16:15 [PATCH] staging: fbtft: name the no-op endian modifier in define_fbtft_write_reg() anshika
@ 2026-08-31  5:47 ` Greg Kroah-Hartman
  2026-08-31  7:07 ` sashiko-bot
  1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-08-31  5:47 UTC (permalink / raw)
  To: anshika
  Cc: Andy Shevchenko, Dan Carpenter, dri-devel, linux-fbdev,
	linux-staging

On Sun, Aug 30, 2026 at 09:45:29PM +0530, anshika wrote:
> Two of the three define_fbtft_write_reg() instantiations pass an empty
> modifier argument, which checkpatch flags as a fragile empty macro
> argument. Give the no-op case an explicit name instead of leaving it
> blank.

Checkpatch is wrong.

> No functional change.
> 
> Link: https://lkml.iu.edu/hypermail/linux/kernel/2602.0/01917.html
> 
> Signed-off-by: anshika <anshikajain196872@gmail.com>

We would need a full name anyway.

Just leave this as-is please, it's fine.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: fbtft: name the no-op endian modifier in define_fbtft_write_reg()
  2026-08-30 16:15 [PATCH] staging: fbtft: name the no-op endian modifier in define_fbtft_write_reg() anshika
  2026-08-31  5:47 ` Greg Kroah-Hartman
@ 2026-08-31  7:07 ` sashiko-bot
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-08-31  7:07 UTC (permalink / raw)
  To: anshika; +Cc: dri-devel

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

Pre-existing issues:
- [High] The define_fbtft_write_reg macro causes a massive buffer overflow and infinite loop if called with len <= 0.
--

commit 058014a775580331d36d8dfcf906e23ec27ea3e9
Author: anshika <anshikajain196872@gmail.com>

staging: fbtft: name the no-op endian modifier in define_fbtft_write_reg()

This commit defines cpu_to_cpu_endian() to act as an explicit no-op endian
modifier. It replaces empty macro arguments in define_fbtft_write_reg()
instantiations to resolve checkpatch warnings about fragile macro usage.

Link: https://lkml.iu.edu/hypermail/linux/kernel/2602.0/01917.html

> diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c
> index 30e436ff19e4c..e03aa251c452a 100644
> --- a/drivers/staging/fbtft/fbtft-bus.c
> +++ b/drivers/staging/fbtft/fbtft-bus.c

[ ... ]

> @@ -62,9 +63,9 @@ out:									      \
>  }                                                                             \
>  EXPORT_SYMBOL(func);
>  
> -define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, )
> +define_fbtft_write_reg(fbtft_write_reg8_bus8, u8, u8, cpu_to_cpu_endian)

[Severity: High]
This isn't a bug introduced by this patch, but since you are modifying these
macro instantiations, I noticed a potential problem in the generated functions.

If any driver path invokes a generated function (such as fbtft_write_reg8_bus8)
with len <= 0, could it cause an infinite loop and an overflow on buf?

Inside the define_fbtft_write_reg() macro, there is no bounds check for 
len <= 0 before decrementing it:

	len--;
	
	if (par->startbyte)
		*(u8 *)par->buf = par->startbyte | 0x2;
		
	if (len) {
		i = len;
		while (i--)
			*buf++ = modifier((data_type)va_arg(args,
							    unsigned int));
	}

If len is <= 0, decrementing len underflows to -1. The check for if (len)
evaluates to true, and while (i--) will execute roughly 4 billion times,
writing out-of-bounds on each iteration.

Unlike fbtft_write_reg8_bus9(), which safely aborts on len <= 0, this macro 
seems to lack a basic bounds check. Should an early check for len <= 0 be
added to the macro to prevent this?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260830161529.14500-1-anshikajain196872@gmail.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-31  7:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-30 16:15 [PATCH] staging: fbtft: name the no-op endian modifier in define_fbtft_write_reg() anshika
2026-08-31  5:47 ` Greg Kroah-Hartman
2026-08-31  7:07 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox