Skip to contentSkip to conversation

drm/gma500: fix a missing break in psb_driver_load

PATCH In review Xiaomeng Tong 2 participants 3 messages Apr 1, 2022 – Apr 7, 2022

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

PATCH 1/1 drm/gma500: fix a missing break in psb_driver_load

Instead of exiting the loop as expected when an entry is found, the list_for_each_entry() continues until the traversal is complete. To avoid potential executing 'ret = gma_backlight_init(dev);' repeatly, break the loop when the entry is found.

---
 drivers/gpu/drm/gma500/psb_drv.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/gma500/psb_drv.c +3 -0
index 2aff54d505e2..b61a8b0eea38 100644
@@ -402,6 +402,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
 			ret = gma_backlight_init(dev);
 			break;
 		}
+
+		if (!ret)
+			break;
 	}
 	drm_connector_list_iter_end(&conn_iter);
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 16 lines · Xiaomeng Tong

Instead of exiting the loop as expected when an entry is found, the list_for_each_entry() continues until the traversal is complete. To avoid potential executing 'ret = gma_backlight_init(dev);' repeatly, break the loop when the entry is found.

---
 drivers/gpu/drm/gma500/psb_drv.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/gma500/psb_drv.c +0 -0
index 2aff54d505e2..b61a8b0eea38 100644

drivers/gpu/drm/gma500/psb_drv.c static int psb_driver_load(struct drm_device *dev, unsigned long flags) · line 407

Quoted 6 lines
drivers/gpu/drm/gma500/psb_drv.c +3 -0
@@ -402,6 +402,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
                        ret = gma_backlight_init(dev);
                        break;
                }
+
+               if (!ret)
+                       break;

Hi,
We cannot do it like this either. If the first connector isn't LVDS or MIPI we would just break out of the iteration because ret is presumably 0 at start and gma_backlight_init() would never run.

-Patrik

Quoted 6 lines
drivers/gpu/drm/gma500/psb_drv.c +0 -1
        }
        drm_connector_list_iter_end(&conn_iter);
 
--

2.17.1

#2 lore raw
Quoted 29 lines · Patrik Jakobsson
Quoted 16 lines · Xiaomeng Tong

Instead of exiting the loop as expected when an entry is found, the list_for_each_entry() continues until the traversal is complete. To avoid potential executing 'ret = gma_backlight_init(dev);' repeatly, break the loop when the entry is found.

---
 drivers/gpu/drm/gma500/psb_drv.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/gma500/psb_drv.c +0 -0
index 2aff54d505e2..b61a8b0eea38 100644

drivers/gpu/drm/gma500/psb_drv.c static int psb_driver_load(struct drm_device *dev, unsigned long flags) · line 407

Quoted 6 lines
drivers/gpu/drm/gma500/psb_drv.c +3 -0
@@ -402,6 +402,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
                        ret = gma_backlight_init(dev);
                        break;
                }
+
+               if (!ret)
+                       break;

Hi,
We cannot do it like this either. If the first connector isn't LVDS or MIPI we would just break out of the iteration because ret is presumably 0 at start and gma_backlight_init() would never run.

Quoted 1 line

-Patrik

Yes, you are correct. I have sent a v2 patch[1]: just goto out; when found. Please check it, thank you very much.

[1]: https://lore.kernel.org/all/[email protected]/

--
Xiaomeng Tong

Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/gma500/psb_drv.c +0 -1
        }
        drm_connector_list_iter_end(&conn_iter);
 
--

2.17.1