Skip to contentSkip to conversation

drm: writeback: Fix drm_writeback_connector_cleanup signature

PATCH Applied Louis Chauvet 2 participants 4 messages Apr 29, 2025 – Jun 23, 2025

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

PATCH v2 1/1 drm: writeback: Fix drm_writeback_connector_cleanup signature

The drm_writeback_connector_cleanup have the signature:

static void drm_writeback_connector_cleanup(
struct drm_device *dev,
struct drm_writeback_connector *wb_connector)

But it is stored and used as a drmres_release_t

    typedef void (*drmres_release_t)(struct drm_device *dev, void *res);

While the current code is valid and does not produce any warning, the CFI runtime check (CONFIG_CFI_CLANG) can fail because the function signature is not the same as drmres_release_t.

In order to fix this, change the function signature to match what is expected by drmres_release_t.

Fixes 1914ba2b91ea ("drm: writeback: Create drmm variants for drm_writeback_connector initialization")

---
Changes in v2:
- Forgot to update the documentation
- Link to v1: https://lore.kernel.org/r/[email protected]

---
 drivers/gpu/drm/drm_writeback.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_writeback.c +4 -3
index edbeab88ff2b..d983ee85cf13 100644
@@ -343,17 +343,18 @@ EXPORT_SYMBOL(drm_writeback_connector_init_with_encoder);
 /**
  * drm_writeback_connector_cleanup - Cleanup the writeback connector
  * @dev: DRM device
- * @wb_connector: Pointer to the writeback connector to clean up
+ * @data: Pointer to the writeback connector to clean up
  *
  * This will decrement the reference counter of blobs and destroy properties. It
  * will also clean the remaining jobs in this writeback connector. Caution: This helper will not
  * clean up the attached encoder and the drm_connector.
  */
 static void drm_writeback_connector_cleanup(struct drm_device *dev,
-					    struct drm_writeback_connector *wb_connector)
+					    void *data)
 {
 	unsigned long flags;
 	struct drm_writeback_job *pos, *n;
+	struct drm_writeback_connector *wb_connector = data;
 
 	delete_writeback_properties(dev);
 	drm_property_blob_put(wb_connector->pixel_formats_blob_ptr);
@@ -405,7 +406,7 @@ int drmm_writeback_connector_init(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	ret = drmm_add_action_or_reset(dev, (void *)drm_writeback_connector_cleanup,
+	ret = drmm_add_action_or_reset(dev, drm_writeback_connector_cleanup,
 				       wb_connector);
 	if (ret)
 		return ret;

---
base-commit: a22e0051f9eb2281b181218d97f77cebc299310d
change-id: 20250428-drm-fix-writeback-cleanup-a1179f3b9691

Best regards,

Signature · 1 line
Louis Chauvet <[email protected]>
#1 lore raw

Hi all,

This patch is pending for 6 weeks, as this is a bug affecting all build with CFI and VKMS (the only user of this API), can someone take a look and apply it?

Thanks a lot,
Louis Chauvet

Le 29/04/2025 à 10:36, Louis Chauvet a écrit :

Quoted 69 lines

The drm_writeback_connector_cleanup have the signature:

static void drm_writeback_connector_cleanup(
struct drm_device *dev,
struct drm_writeback_connector *wb_connector)

But it is stored and used as a drmres_release_t

     typedef void (*drmres_release_t)(struct drm_device *dev, void *res);

While the current code is valid and does not produce any warning, the CFI runtime check (CONFIG_CFI_CLANG) can fail because the function signature is not the same as drmres_release_t.

In order to fix this, change the function signature to match what is expected by drmres_release_t.

Fixes 1914ba2b91ea ("drm: writeback: Create drmm variants for drm_writeback_connector initialization")

---
Changes in v2:
- Forgot to update the documentation
- Link to v1: https://lore.kernel.org/r/[email protected]

---
  drivers/gpu/drm/drm_writeback.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_writeback.c +4 -4
index edbeab88ff2b..d983ee85cf13 100644
@@ -343,17 +343,18 @@ EXPORT_SYMBOL(drm_writeback_connector_init_with_encoder);
  /**
   * drm_writeback_connector_cleanup - Cleanup the writeback connector
   * @dev: DRM device
- * @wb_connector: Pointer to the writeback connector to clean up
+ * @data: Pointer to the writeback connector to clean up
   *
   * This will decrement the reference counter of blobs and destroy properties. It
   * will also clean the remaining jobs in this writeback connector. Caution: This helper will not
   * clean up the attached encoder and the drm_connector.
   */
  static void drm_writeback_connector_cleanup(struct drm_device *dev,
-					    struct drm_writeback_connector *wb_connector)
+					    void *data)
  {
  	unsigned long flags;
  	struct drm_writeback_job *pos, *n;
+	struct drm_writeback_connector *wb_connector = data;
 
  	delete_writeback_properties(dev);
  	drm_property_blob_put(wb_connector->pixel_formats_blob_ptr);
@@ -405,7 +406,7 @@ int drmm_writeback_connector_init(struct drm_device *dev,
  	if (ret)
  		return ret;
 
-	ret = drmm_add_action_or_reset(dev, (void *)drm_writeback_connector_cleanup,
+	ret = drmm_add_action_or_reset(dev, drm_writeback_connector_cleanup,
  				       wb_connector);
  	if (ret)
  		return ret;
 
---

base-commit: a22e0051f9eb2281b181218d97f77cebc299310d
change-id: 20250428-drm-fix-writeback-cleanup-a1179f3b9691

Best regards,

Signature · 3 lines
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
Reviewed-by on v2 1/1
#2 lore raw
In reply to Louis Chauvet

Hi Louis,

Quoted 14 lines · Louis Chauvet

The drm_writeback_connector_cleanup have the signature:

static void drm_writeback_connector_cleanup(
struct drm_device *dev,
struct drm_writeback_connector *wb_connector)

But it is stored and used as a drmres_release_t

     typedef void (*drmres_release_t)(struct drm_device *dev, void *res);

While the current code is valid and does not produce any warning, the CFI runtime check (CONFIG_CFI_CLANG) can fail because the function signature is not the same as drmres_release_t.

Quoted 7 lines

In order to fix this, change the function signature to match what is expected by drmres_release_t.

Fixes 1914ba2b91ea ("drm: writeback: Create drmm variants for drm_writeback_connector initialization")

Best Regards,
- Maíra

Quoted 48 lines

---
Changes in v2:
- Forgot to update the documentation
- Link to v1: https://lore.kernel.org/r/[email protected]

---
  drivers/gpu/drm/drm_writeback.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_writeback.c +4 -4
index edbeab88ff2b..d983ee85cf13 100644
@@ -343,17 +343,18 @@ EXPORT_SYMBOL(drm_writeback_connector_init_with_encoder);
  /**
   * drm_writeback_connector_cleanup - Cleanup the writeback connector
   * @dev: DRM device
- * @wb_connector: Pointer to the writeback connector to clean up
+ * @data: Pointer to the writeback connector to clean up
   *
   * This will decrement the reference counter of blobs and destroy properties. It
   * will also clean the remaining jobs in this writeback connector. Caution: This helper will not
   * clean up the attached encoder and the drm_connector.
   */
  static void drm_writeback_connector_cleanup(struct drm_device *dev,
-					    struct drm_writeback_connector *wb_connector)
+					    void *data)
  {
  	unsigned long flags;
  	struct drm_writeback_job *pos, *n;
+	struct drm_writeback_connector *wb_connector = data;
 
  	delete_writeback_properties(dev);
  	drm_property_blob_put(wb_connector->pixel_formats_blob_ptr);
@@ -405,7 +406,7 @@ int drmm_writeback_connector_init(struct drm_device *dev,
  	if (ret)
  		return ret;
 
-	ret = drmm_add_action_or_reset(dev, (void *)drm_writeback_connector_cleanup,
+	ret = drmm_add_action_or_reset(dev, drm_writeback_connector_cleanup,
  				       wb_connector);
  	if (ret)
  		return ret;
 
---

base-commit: a22e0051f9eb2281b181218d97f77cebc299310d
change-id: 20250428-drm-fix-writeback-cleanup-a1179f3b9691

Best regards,

author Applied
#3 lore raw
In reply to Louis Chauvet
Quoted 9 lines · Louis Chauvet

The drm_writeback_connector_cleanup have the signature:

static void drm_writeback_connector_cleanup(
struct drm_device *dev,
struct drm_writeback_connector *wb_connector)

But it is stored and used as a drmres_release_t

[...]

Applied, thanks!

[1/1] drm: writeback: Fix drm_writeback_connector_cleanup signature

      commit: fb721b2c35b1829b8ecf62e3adb41cf30260316a

Best regards,

Signature · 1 line
Louis Chauvet <[email protected]>