Skip to contentSkip to conversation

drm: xlnx: Fix return type of zynqmp_dp_bridge_mode_valid

PATCH In review Nathan Chancellor 3 participants 3 messages Nov 9, 2022

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

PATCH v2 1/1 drm: xlnx: Fix return type of zynqmp_dp_bridge_mode_valid

From: Nathan Huckleberry <[email protected]>

The mode_valid field in drm_bridge_helper_funcs is expected to be of type
enum drm_mode_status (* mode_valid) (struct drm_bridge *bridge,

                                     struct drm_display_mode *mode);

The mismatched return type breaks forward edge kCFI since the underlying function definition does not match the function hook definition. A new warning in clang will catch this at compile time:

drivers/gpu/drm/xlnx/zynqmp_dp.c:1573:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' with an expression of type 'int (struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.mode_valid = zynqmp_dp_bridge_mode_valid,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

The return type of zynqmp_dp_bridge_mode_valid should be changed from int to enum drm_mode_status.

[nathan: Rebase on drm-misc-next and fix conflicts
Add note about new clang warning]

---

Please consider picking this up so that it makes 6.2.

v2:
- Take over for Nathan, as he is busy with other matters.
- Rebase on drm-misc-next and resolve conflicts.
- Add a note about new clang warning that will catch this issue at compile time.

v1: https://lore.kernel.org/[email protected]/

 drivers/gpu/drm/xlnx/zynqmp_dp.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/xlnx/zynqmp_dp.c +4 -3
index 7c9ae167eac7..0a7b466446fb 100644
@@ -1362,9 +1362,10 @@ static void zynqmp_dp_bridge_detach(struct drm_bridge *bridge)
 	zynqmp_dp_aux_cleanup(dp);
 }
 
-static int zynqmp_dp_bridge_mode_valid(struct drm_bridge *bridge,
-				       const struct drm_display_info *info,
-				       const struct drm_display_mode *mode)
+static enum drm_mode_status
+zynqmp_dp_bridge_mode_valid(struct drm_bridge *bridge,
+			    const struct drm_display_info *info,
+			    const struct drm_display_mode *mode)
 {
 	struct zynqmp_dp *dp = bridge_to_dp(bridge);
 	int rate;

base-commit: 1a0257c352638916fdaffaac2ddedb8e049312f3

Signature · 1 line
2.38.1
maintainer
#1 lore raw

Hi Nathan,

Thank you for the patch.

Quoted 24 lines · Nathan Chancellor

From: Nathan Huckleberry <[email protected]>

The mode_valid field in drm_bridge_helper_funcs is expected to be of type
enum drm_mode_status (* mode_valid) (struct drm_bridge *bridge,

                                     struct drm_display_mode *mode);

The mismatched return type breaks forward edge kCFI since the underlying function definition does not match the function hook definition. A new warning in clang will catch this at compile time:

drivers/gpu/drm/xlnx/zynqmp_dp.c:1573:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' with an expression of type 'int (struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.mode_valid = zynqmp_dp_bridge_mode_valid,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

The return type of zynqmp_dp_bridge_mode_valid should be changed from int to enum drm_mode_status.

Quoted 6 lines

[nathan: Rebase on drm-misc-next and fix conflicts
Add note about new clang warning]

---

Please consider picking this up so that it makes 6.2.

I'll send a pull request shortly.

Quoted 31 lines

v2:
- Take over for Nathan, as he is busy with other matters.
- Rebase on drm-misc-next and resolve conflicts.
- Add a note about new clang warning that will catch this issue at compile time.

v1: https://lore.kernel.org/[email protected]/

 drivers/gpu/drm/xlnx/zynqmp_dp.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/xlnx/zynqmp_dp.c +4 -3
index 7c9ae167eac7..0a7b466446fb 100644
@@ -1362,9 +1362,10 @@ static void zynqmp_dp_bridge_detach(struct drm_bridge *bridge)
 	zynqmp_dp_aux_cleanup(dp);
 }
 
-static int zynqmp_dp_bridge_mode_valid(struct drm_bridge *bridge,
-				       const struct drm_display_info *info,
-				       const struct drm_display_mode *mode)
+static enum drm_mode_status
+zynqmp_dp_bridge_mode_valid(struct drm_bridge *bridge,
+			    const struct drm_display_info *info,
+			    const struct drm_display_mode *mode)
 {
 	struct zynqmp_dp *dp = bridge_to_dp(bridge);
 	int rate;

base-commit: 1a0257c352638916fdaffaac2ddedb8e049312f3

Signature · 3 lines
Regards,

Laurent Pinchart
Reviewed-by on v2 1/1
#2 lore raw
In reply to Nathan Chancellor
Quoted 16 lines · Nathan Chancellor

From: Nathan Huckleberry <[email protected]>

The mode_valid field in drm_bridge_helper_funcs is expected to be of type
enum drm_mode_status (* mode_valid) (struct drm_bridge *bridge,

                                     struct drm_display_mode *mode);

The mismatched return type breaks forward edge kCFI since the underlying function definition does not match the function hook definition. A new warning in clang will catch this at compile time:

drivers/gpu/drm/xlnx/zynqmp_dp.c:1573:16: error: incompatible function pointer types initializing 'enum drm_mode_status (*)(struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' with an expression of type 'int (struct drm_bridge *, const struct drm_display_info *, const struct drm_display_mode *)' [-Werror,-Wincompatible-function-pointer-types-strict]
.mode_valid = zynqmp_dp_bridge_mode_valid,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Quoted 7 lines

The return type of zynqmp_dp_bridge_mode_valid should be changed from int to enum drm_mode_status.

Signature · 1 line
Kees Cook