Skip to content
Snippets Groups Projects
  1. Mar 20, 2023
  2. Jan 20, 2023
  3. Dec 01, 2022
  4. Sep 20, 2022
  5. Aug 29, 2022
  6. Jul 05, 2022
  7. Jun 13, 2022
  8. Apr 25, 2022
  9. Apr 22, 2022
  10. Apr 19, 2022
  11. Mar 31, 2022
  12. Mar 14, 2022
    • Ville Syrjälä's avatar
      drm/bridge: Use drm_mode_copy() · d008bc33
      Ville Syrjälä authored
      
      struct drm_display_mode embeds a list head, so overwriting
      the full struct with another one will corrupt the list
      (if the destination mode is on a list). Use drm_mode_copy()
      instead which explicitly preserves the list head of
      the destination mode.
      
      Even if we know the destination mode is not on any list
      using drm_mode_copy() seems decent as it sets a good
      example. Bad examples of not using it might eventually
      get copied into code where preserving the list head
      actually matters.
      
      Obviously one case not covered here is when the mode
      itself is embedded in a larger structure and the whole
      structure is copied. But if we are careful when copying
      into modes embedded in structures I think we can be a
      little more reassured that bogus list heads haven't been
      propagated in.
      
      @is_mode_copy@
      @@
      drm_mode_copy(...)
      {
      ...
      }
      
      @depends on !is_mode_copy@
      struct drm_display_mode *mode;
      expression E, S;
      @@
      (
      - *mode = E
      + drm_mode_copy(mode, &E)
      |
      - memcpy(mode, E, S)
      + drm_mode_copy(mode, E)
      )
      
      @depends on !is_mode_copy@
      struct drm_display_mode mode;
      expression E;
      @@
      (
      - mode = E
      + drm_mode_copy(&mode, &E)
      |
      - memcpy(&mode, E, S)
      + drm_mode_copy(&mode, E)
      )
      
      @@
      struct drm_display_mode *mode;
      @@
      - &*mode
      + mode
      
      Cc: Andrzej Hajda <andrzej.hajda@intel.com>
      Cc: Neil Armstrong <narmstrong@baylibre.com>
      Cc: Robert Foss <robert.foss@linaro.org>
      Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>
      Cc: Jonas Karlman <jonas@kwiboo.se>
      Cc: Jernej Skrabec <jernej.skrabec@gmail.com>
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220218100403.7028-7-ville.syrjala@linux.intel.com
      
      
      Reviewed-by: default avatarAndrzej Hajda <andrzej.hajda@intel.com>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      d008bc33
  13. Feb 10, 2022
  14. Jan 25, 2022
  15. Jan 13, 2022
  16. Jan 05, 2022
  17. Jan 04, 2022
  18. Nov 12, 2021
  19. Oct 15, 2021
  20. Oct 06, 2021
  21. Jul 28, 2021
  22. Jul 27, 2021
  23. May 07, 2021
  24. Apr 20, 2021
  25. Jan 05, 2021
  26. Nov 12, 2020
  27. Oct 05, 2020
  28. Sep 11, 2020
  29. Sep 08, 2020
  30. Sep 07, 2020
Loading