dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] drm/gma500: fix a potential repeat execution in psb_driver_load
@ 2022-04-13  5:11 Xiaomeng Tong
  2022-04-20  7:34 ` Patrik Jakobsson
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaomeng Tong @ 2022-04-13  5:11 UTC (permalink / raw)
  To: patrik.r.jakobsson, airlied, daniel
  Cc: Xiaomeng Tong, linux-kernel, dri-devel

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,
goto outside the loop when found entry by replacing switch/case with
if statement.

Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
---
changes since v2:
 - replace switch with if statement (Patrik Jakobsson)

changes since v1:
 - goto outside the loop (Xiaomeng Tong)

v2: https://lore.kernel.org/dri-devel/20220406113143.10699-1-xiam0nd.tong@gmail.com/
v1: https://lore.kernel.org/lkml/20220401115811.9656-1-xiam0nd.tong@gmail.com/
---
 drivers/gpu/drm/gma500/psb_drv.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 2aff54d505e2..85211ec16e52 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -396,9 +396,8 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
 	drm_for_each_connector_iter(connector, &conn_iter) {
 		gma_encoder = gma_attached_encoder(connector);
 
-		switch (gma_encoder->type) {
-		case INTEL_OUTPUT_LVDS:
-		case INTEL_OUTPUT_MIPI:
+		if (gma_encoder->type == INTEL_OUTPUT_LVDS ||
+			gma_encoder->type == INTEL_OUTPUT_MIPI) {
 			ret = gma_backlight_init(dev);
 			break;
 		}
-- 
2.17.1


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

* Re: [PATCH v3] drm/gma500: fix a potential repeat execution in psb_driver_load
  2022-04-13  5:11 [PATCH v3] drm/gma500: fix a potential repeat execution in psb_driver_load Xiaomeng Tong
@ 2022-04-20  7:34 ` Patrik Jakobsson
  0 siblings, 0 replies; 2+ messages in thread
From: Patrik Jakobsson @ 2022-04-20  7:34 UTC (permalink / raw)
  To: Xiaomeng Tong; +Cc: David Airlie, dri-devel, linux-kernel

On Wed, Apr 13, 2022 at 7:11 AM Xiaomeng Tong <xiam0nd.tong@gmail.com> wrote:
>
> 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,
> goto outside the loop when found entry by replacing switch/case with
> if statement.
>
> Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>

Thanks for the patch. I've applied it to drm-misc-next.

I fixed up an indentation issue on the second line.

Cheers
Patrik

> ---
> changes since v2:
>  - replace switch with if statement (Patrik Jakobsson)
>
> changes since v1:
>  - goto outside the loop (Xiaomeng Tong)
>
> v2: https://lore.kernel.org/dri-devel/20220406113143.10699-1-xiam0nd.tong@gmail.com/
> v1: https://lore.kernel.org/lkml/20220401115811.9656-1-xiam0nd.tong@gmail.com/
> ---
>  drivers/gpu/drm/gma500/psb_drv.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
> index 2aff54d505e2..85211ec16e52 100644
> --- a/drivers/gpu/drm/gma500/psb_drv.c
> +++ b/drivers/gpu/drm/gma500/psb_drv.c
> @@ -396,9 +396,8 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
>         drm_for_each_connector_iter(connector, &conn_iter) {
>                 gma_encoder = gma_attached_encoder(connector);
>
> -               switch (gma_encoder->type) {
> -               case INTEL_OUTPUT_LVDS:
> -               case INTEL_OUTPUT_MIPI:
> +               if (gma_encoder->type == INTEL_OUTPUT_LVDS ||
> +                       gma_encoder->type == INTEL_OUTPUT_MIPI) {
>                         ret = gma_backlight_init(dev);
>                         break;
>                 }
> --
> 2.17.1
>

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

end of thread, other threads:[~2022-04-20  7:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13  5:11 [PATCH v3] drm/gma500: fix a potential repeat execution in psb_driver_load Xiaomeng Tong
2022-04-20  7:34 ` Patrik Jakobsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).