Skip to contentSkip to conversation

drm/sysfb: Fix a NULL vs IS_ERR() bug

PATCH In review Dan Carpenter 3 participants 4 messages Oct 17, 2025 – Oct 19, 2025 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/sysfb: Fix a NULL vs IS_ERR() bug

The drm_atomic_get_crtc_state() function never returns NULL, it returns error pointers. Update the error checking to match.

Fixes cb71de092553 ("drm/sysfb: Lookup blit function during atomic check")
---
 drivers/gpu/drm/sysfb/drm_sysfb_modeset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/sysfb/drm_sysfb_modeset.c +1 -1
index 8517c490e815..d2c4d8f3d4d0 100644
@@ -259,7 +259,7 @@ int drm_sysfb_plane_helper_begin_fb_access(struct drm_plane *plane,
 	ret = -EINVAL;
 
 	crtc_state = drm_atomic_get_crtc_state(plane_state->state, plane_state->crtc);
-	if (drm_WARN_ON_ONCE(dev, !crtc_state))
+	if (drm_WARN_ON_ONCE(dev, IS_ERR(crtc_state)))
 		goto err_drm_gem_end_shadow_fb_access;
 	sysfb_crtc_state = to_drm_sysfb_crtc_state(crtc_state);
 
Signature · 1 line
2.51.0
#1 lore raw
Quoted 14 lines · Dan Carpenter

The drm_atomic_get_crtc_state() function never returns NULL, it returns error pointers. Update the error checking to match.

Fixes cb71de092553 ("drm/sysfb: Lookup blit function during atomic check")
---
 drivers/gpu/drm/sysfb/drm_sysfb_modeset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/sysfb/drm_sysfb_modeset.c +0 -0
index 8517c490e815..d2c4d8f3d4d0 100644

drivers/gpu/drm/sysfb/drm_sysfb_modeset.c int drm_sysfb_plane_helper_begin_fb_access(struct drm_plane *plane, · line 261

Quoted 3 lines
drivers/gpu/drm/sysfb/drm_sysfb_modeset.c +0 -0
@@ -259,7 +259,7 @@ int drm_sysfb_plane_helper_begin_fb_access(struct drm_plane *plane,
 	ret = -EINVAL;
 
 	crtc_state = drm_atomic_get_crtc_state(plane_state->state, plane_state->crtc);

Looking at where this gets called, that should be drm_atomic_get_new_crtc_state(). Either that or the code is more seriously borked.

I'll send out a patch that warns about invalid use of *_get_state()...

Quoted 7 lines
drivers/gpu/drm/sysfb/drm_sysfb_modeset.c +1 -1
-	if (drm_WARN_ON_ONCE(dev, !crtc_state))
+	if (drm_WARN_ON_ONCE(dev, IS_ERR(crtc_state)))
 		goto err_drm_gem_end_shadow_fb_access;
 	sysfb_crtc_state = to_drm_sysfb_crtc_state(crtc_state);
 
Signature · 1 line
2.51.0
Signature · 2 lines
Ville Syrjälä
Intel
#2 lore raw
Quoted 17 lines · Ville Syrjälä
Quoted 16 lines · Dan Carpenter

The drm_atomic_get_crtc_state() function never returns NULL, it returns error pointers. Update the error checking to match.

Fixes cb71de092553 ("drm/sysfb: Lookup blit function during atomic check")
---
 drivers/gpu/drm/sysfb/drm_sysfb_modeset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/sysfb/drm_sysfb_modeset.c +0 -0
index 8517c490e815..d2c4d8f3d4d0 100644
@@ -259,7 +259,7 @@ int drm_sysfb_plane_helper_begin_fb_access(struct drm_plane *plane,
 	ret = -EINVAL;
 
Quoted 6 lines

drivers/gpu/drm/sysfb/drm_sysfb_modeset.c int drm_sysfb_plane_helper_begin_fb_access(struct drm_plane *plane, · line 261

Quoted 1 line
drivers/gpu/drm/sysfb/drm_sysfb_modeset.c +0 -0
 	crtc_state = drm_atomic_get_crtc_state(plane_state->state, plane_state->crtc);

Looking at where this gets called, that should be drm_atomic_get_new_crtc_state(). Either that or the code is more seriously borked.

I can't comment on that. Let's drop this patch and instead (probably I guess?) change it to drm_atomic_get_new_crtc_state().

regards,
dan carpenter

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

(cc dri-devel)

Am 19.10.25 um 17:06 schrieb Thomas Zimmermann:

Quoted 44 lines

Hi

Am 17.10.25 um 18:15 schrieb Ville Syrjälä:

Quoted 10 lines · Dan Carpenter
Quoted 9 lines

The drm_atomic_get_crtc_state() function never returns NULL, it returns error pointers.  Update the error checking to match.

Fixes cb71de092553 ("drm/sysfb: Lookup blit function during atomic check")

---
  drivers/gpu/drm/sysfb/drm_sysfb_modeset.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 11 lines

drivers/gpu/drm/sysfb/drm_sysfb_modeset.c int · line 261

Quoted 8 lines
drivers/gpu/drm/sysfb/drm_sysfb_modeset.c +0 -0
index 8517c490e815..d2c4d8f3d4d0 100644
@@ -259,7 +259,7 @@ int 
 drm_sysfb_plane_helper_begin_fb_access(struct drm_plane *plane,
       ret = -EINVAL;
         crtc_state = drm_atomic_get_crtc_state(plane_state->state, plane_state->crtc);

Looking at where this gets called, that should be drm_atomic_get_new_crtc_state(). Either that or the code is more seriously borked.

Yes that should be get_new_crtc_state. Thanks for spotting the bug.

Quoted 3 lines

I'll send out a patch that warns about invalid use of *_get_state()...

If that is possible, I'd welcome it very much. State handling seems like one of the dark corners of the DRM framework.

Best regards
Thomas

Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/sysfb/drm_sysfb_modeset.c +1 -1
-    if (drm_WARN_ON_ONCE(dev, !crtc_state))
+    if (drm_WARN_ON_ONCE(dev, IS_ERR(crtc_state)))
           goto err_drm_gem_end_shadow_fb_access;
       sysfb_crtc_state = to_drm_sysfb_crtc_state(crtc_state);

  --
2.51.0

Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)