diff mbox series

drm/xe/display: check for error on drmm_mutex_init

Message ID 20240321060124.4074773-1-arun.r.murthy@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/xe/display: check for error on drmm_mutex_init | expand

Commit Message

Murthy, Arun R March 21, 2024, 6:01 a.m. UTC
Check return value for drmm_mutex_init as it can fail and return on
failure.

Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
---
 drivers/gpu/drm/xe/display/xe_display.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Jani Nikula March 21, 2024, 9:43 a.m. UTC | #1
On Thu, 21 Mar 2024, Arun R Murthy <arun.r.murthy@intel.com> wrote:
> Check return value for drmm_mutex_init as it can fail and return on
> failure.
>
> Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
> ---
>  drivers/gpu/drm/xe/display/xe_display.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/display/xe_display.c b/drivers/gpu/drm/xe/display/xe_display.c
> index e4db069f0db3..ac2e58d1fa82 100644
> --- a/drivers/gpu/drm/xe/display/xe_display.c
> +++ b/drivers/gpu/drm/xe/display/xe_display.c
> @@ -107,12 +107,14 @@ int xe_display_create(struct xe_device *xe)
>  
>  	xe->display.hotplug.dp_wq = alloc_ordered_workqueue("xe-dp", 0);
>  
> -	drmm_mutex_init(&xe->drm, &xe->sb_lock);
> -	drmm_mutex_init(&xe->drm, &xe->display.backlight.lock);
> -	drmm_mutex_init(&xe->drm, &xe->display.audio.mutex);
> -	drmm_mutex_init(&xe->drm, &xe->display.wm.wm_mutex);
> -	drmm_mutex_init(&xe->drm, &xe->display.pps.mutex);
> -	drmm_mutex_init(&xe->drm, &xe->display.hdcp.hdcp_mutex);
> +	if ((drmm_mutex_init(&xe->drm, &xe->sb_lock)) ||
> +	    (drmm_mutex_init(&xe->drm, &xe->display.backlight.lock)) ||
> +	    (drmm_mutex_init(&xe->drm, &xe->display.audio.mutex)) ||
> +	    (drmm_mutex_init(&xe->drm, &xe->display.wm.wm_mutex)) ||
> +	    (drmm_mutex_init(&xe->drm, &xe->display.pps.mutex)) ||
> +	    (drmm_mutex_init(&xe->drm, &xe->display.hdcp.hdcp_mutex)))

Excessive parentheses.

BR,
Jani.

> +		return -ENOMEM;
> +
>  	xe->enabled_irq_mask = ~0;
>  
>  	err = drmm_add_action_or_reset(&xe->drm, display_destroy, NULL);
Lucas De Marchi March 22, 2024, 8:51 p.m. UTC | #2
On Thu, Mar 21, 2024 at 11:31:24AM +0530, Arun R Murthy wrote:
>Check return value for drmm_mutex_init as it can fail and return on
>failure.
>
>Signed-off-by: Arun R Murthy <arun.r.murthy@intel.com>
>---
> drivers/gpu/drm/xe/display/xe_display.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/display/xe_display.c b/drivers/gpu/drm/xe/display/xe_display.c
>index e4db069f0db3..ac2e58d1fa82 100644
>--- a/drivers/gpu/drm/xe/display/xe_display.c
>+++ b/drivers/gpu/drm/xe/display/xe_display.c
>@@ -107,12 +107,14 @@ int xe_display_create(struct xe_device *xe)
>
> 	xe->display.hotplug.dp_wq = alloc_ordered_workqueue("xe-dp", 0);
>
>-	drmm_mutex_init(&xe->drm, &xe->sb_lock);
>-	drmm_mutex_init(&xe->drm, &xe->display.backlight.lock);
>-	drmm_mutex_init(&xe->drm, &xe->display.audio.mutex);
>-	drmm_mutex_init(&xe->drm, &xe->display.wm.wm_mutex);
>-	drmm_mutex_init(&xe->drm, &xe->display.pps.mutex);
>-	drmm_mutex_init(&xe->drm, &xe->display.hdcp.hdcp_mutex);
>+	if ((drmm_mutex_init(&xe->drm, &xe->sb_lock)) ||

     	   ^^

you only need 2 parenthesis if you were going to record the return.

Lucas De Marchi
diff mbox series

Patch

diff --git a/drivers/gpu/drm/xe/display/xe_display.c b/drivers/gpu/drm/xe/display/xe_display.c
index e4db069f0db3..ac2e58d1fa82 100644
--- a/drivers/gpu/drm/xe/display/xe_display.c
+++ b/drivers/gpu/drm/xe/display/xe_display.c
@@ -107,12 +107,14 @@  int xe_display_create(struct xe_device *xe)
 
 	xe->display.hotplug.dp_wq = alloc_ordered_workqueue("xe-dp", 0);
 
-	drmm_mutex_init(&xe->drm, &xe->sb_lock);
-	drmm_mutex_init(&xe->drm, &xe->display.backlight.lock);
-	drmm_mutex_init(&xe->drm, &xe->display.audio.mutex);
-	drmm_mutex_init(&xe->drm, &xe->display.wm.wm_mutex);
-	drmm_mutex_init(&xe->drm, &xe->display.pps.mutex);
-	drmm_mutex_init(&xe->drm, &xe->display.hdcp.hdcp_mutex);
+	if ((drmm_mutex_init(&xe->drm, &xe->sb_lock)) ||
+	    (drmm_mutex_init(&xe->drm, &xe->display.backlight.lock)) ||
+	    (drmm_mutex_init(&xe->drm, &xe->display.audio.mutex)) ||
+	    (drmm_mutex_init(&xe->drm, &xe->display.wm.wm_mutex)) ||
+	    (drmm_mutex_init(&xe->drm, &xe->display.pps.mutex)) ||
+	    (drmm_mutex_init(&xe->drm, &xe->display.hdcp.hdcp_mutex)))
+		return -ENOMEM;
+
 	xe->enabled_irq_mask = ~0;
 
 	err = drmm_add_action_or_reset(&xe->drm, display_destroy, NULL);