Re: [PATCH] drm: msm: Fix return type of dsi_mgr_connector_mode_valid for kCFI
From: Nick Desaulniers
Date: Wed Jan 29 2020 - 16:45:38 EST
On Wed, Jan 29, 2020 at 12:12 PM John Stultz <john.stultz@xxxxxxxxxx> wrote:
>
> I was hitting kCFI crashes when building with clang, and after
> some digging finally narrowed it down to the
> dsi_mgr_connector_mode_valid() function being implemented as
> returning an int, instead of an enum drm_mode_status.
>
> This patch fixes it, and appeases the opaque word of the kCFI
> gods (seriously, clang inlining everything makes the kCFI
> backtraces only really rough estimates of where things went
> wrong).
>
> Thanks as always to Sami for his help narrowing this down.
>
> Cc: Rob Clark <robdclark@xxxxxxxxx>
> Cc: Sean Paul <sean@xxxxxxxxxx>
> Cc: Sami Tolvanen <samitolvanen@xxxxxxxxxx>
> Cc: Todd Kjos <tkjos@xxxxxxxxxx>
> Cc: Alistair Delva <adelva@xxxxxxxxxx>
> Cc: Amit Pundir <amit.pundir@xxxxxxxxxx>
> Cc: Sumit Semwal <sumit.semwal@xxxxxxxxxx>
> Cc: freedreno@xxxxxxxxxxxxxxxxxxxxx
> Cc: clang-built-linux@xxxxxxxxxxxxxxxx
> Signed-off-by: John Stultz <john.stultz@xxxxxxxxxx>
John, thanks for fixing this. Our inliner is a point of pride
(inlining indirect function calls; you're welcome). ;)
Indeed, the function pointer member `mode_valid` in `struct
drm_connector_helper_funcs` in
include/drm/drm_modeset_helper_vtables.h returns an `enum
drm_mode_status`.
Reviewed-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
> ---
> drivers/gpu/drm/msm/dsi/dsi_manager.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/dsi/dsi_manager.c b/drivers/gpu/drm/msm/dsi/dsi_manager.c
> index 271aa7bbca925..355a60b4a536f 100644
> --- a/drivers/gpu/drm/msm/dsi/dsi_manager.c
> +++ b/drivers/gpu/drm/msm/dsi/dsi_manager.c
> @@ -336,7 +336,7 @@ static int dsi_mgr_connector_get_modes(struct drm_connector *connector)
> return num;
> }
>
> -static int dsi_mgr_connector_mode_valid(struct drm_connector *connector,
> +static enum drm_mode_status dsi_mgr_connector_mode_valid(struct drm_connector *connector,
> struct drm_display_mode *mode)
> {
> int id = dsi_mgr_connector_get_id(connector);
> --
--
Thanks,
~Nick Desaulniers