# \[PATCH\] fbdev: core: fix ubsan warning in pixel\_to\_pat

- From: Zsolt Kajtar \<soci@c64.rulez.org\>
- Date: 2025-08-21 02:54:01 
- List: linux-fbdev
- Page: https://ratatoskr.run/linux-fbdev/2025/08/9264280
- Thread: https://ratatoskr.run/linux-fbdev/2025/08/9264280/t.md

```text
It could be triggered on 32 bit big endian machines at 32 bpp in the
pattern realignment. In this case just return early as the result is
an identity.

Signed-off-by: Zsolt Kajtar <soci@c64.rulez.org>
---
 drivers/video/fbdev/core/fb_fillrect.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/core/fb_fillrect.h b/drivers/video/fbdev/core/fb_fillrect.h
index 66042e534..f366670a5 100644
--- a/drivers/video/fbdev/core/fb_fillrect.h
+++ b/drivers/video/fbdev/core/fb_fillrect.h
@@ -92,8 +92,7 @@ static unsigned long pixel_to_pat(int bpp, u32 color)
 		pattern = pattern | pattern << bpp;
 		break;
 	default:
-		pattern = color;
-		break;
+		return color;
 	}
 #ifndef __LITTLE_ENDIAN
 	pattern <<= (BITS_PER_LONG % bpp);
-- 
2.30.2

```
