linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma-buf: fix compare in WARN_ON_ONCE
@ 2025-06-05  8:53 Christian König
  2025-06-10 14:07 ` Christian König
  2025-06-10 14:17 ` Tvrtko Ursulin
  0 siblings, 2 replies; 3+ messages in thread
From: Christian König @ 2025-06-05  8:53 UTC (permalink / raw)
  To: dan.carpenter, sumit.semwal, linux-media, dri-devel,
	linaro-mm-sig
  Cc: Christian König

Smatch pointed out this trivial typo:
	drivers/dma-buf/dma-buf.c:1123 dma_buf_map_attachment()
	warn: passing positive error code '16' to 'ERR_PTR'

drivers/dma-buf/dma-buf.c
    1113         dma_resv_assert_held(attach->dmabuf->resv);
    1114
    1115         if (dma_buf_pin_on_map(attach)) {
    1116                 ret = attach->dmabuf->ops->pin(attach);
    1117                 /*
    1118                  * Catch exporters making buffers inaccessible even when
    1119                  * attachments preventing that exist.
    1120                  */
    1121                 WARN_ON_ONCE(ret == EBUSY);
                                             ^^^^^
This was probably intended to be -EBUSY?

    1122                 if (ret)
--> 1123                         return ERR_PTR(ret);
                                                ^^^
Otherwise we will eventually crash.

    1124         }
    1125
    1126         sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
    1127         if (!sg_table)
    1128                 sg_table = ERR_PTR(-ENOMEM);
    1129         if (IS_ERR(sg_table))
    1130                 goto error_unpin;
    1131

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/dma-buf/dma-buf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 0c48d41dd5eb..451714008e8a 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -1060,7 +1060,7 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
 		 * Catch exporters making buffers inaccessible even when
 		 * attachments preventing that exist.
 		 */
-		WARN_ON_ONCE(ret == EBUSY);
+		WARN_ON_ONCE(ret == -EBUSY);
 		if (ret)
 			return ERR_PTR(ret);
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-buf: fix compare in WARN_ON_ONCE
  2025-06-05  8:53 [PATCH] dma-buf: fix compare in WARN_ON_ONCE Christian König
@ 2025-06-10 14:07 ` Christian König
  2025-06-10 14:17 ` Tvrtko Ursulin
  1 sibling, 0 replies; 3+ messages in thread
From: Christian König @ 2025-06-10 14:07 UTC (permalink / raw)
  To: Christian König, dan.carpenter, sumit.semwal, linux-media,
	dri-devel, linaro-mm-sig, Simona Vetter

Gentle ping, can anybody give me a quick rb for this trivial fix?

Thanks,
Christian.

On 6/5/25 10:53, Christian König wrote:
> Smatch pointed out this trivial typo:
> 	drivers/dma-buf/dma-buf.c:1123 dma_buf_map_attachment()
> 	warn: passing positive error code '16' to 'ERR_PTR'
> 
> drivers/dma-buf/dma-buf.c
>     1113         dma_resv_assert_held(attach->dmabuf->resv);
>     1114
>     1115         if (dma_buf_pin_on_map(attach)) {
>     1116                 ret = attach->dmabuf->ops->pin(attach);
>     1117                 /*
>     1118                  * Catch exporters making buffers inaccessible even when
>     1119                  * attachments preventing that exist.
>     1120                  */
>     1121                 WARN_ON_ONCE(ret == EBUSY);
>                                              ^^^^^
> This was probably intended to be -EBUSY?
> 
>     1122                 if (ret)
> --> 1123                         return ERR_PTR(ret);
>                                                 ^^^
> Otherwise we will eventually crash.
> 
>     1124         }
>     1125
>     1126         sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
>     1127         if (!sg_table)
>     1128                 sg_table = ERR_PTR(-ENOMEM);
>     1129         if (IS_ERR(sg_table))
>     1130                 goto error_unpin;
>     1131
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/dma-buf/dma-buf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 0c48d41dd5eb..451714008e8a 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -1060,7 +1060,7 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
>  		 * Catch exporters making buffers inaccessible even when
>  		 * attachments preventing that exist.
>  		 */
> -		WARN_ON_ONCE(ret == EBUSY);
> +		WARN_ON_ONCE(ret == -EBUSY);
>  		if (ret)
>  			return ERR_PTR(ret);
>  	}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-buf: fix compare in WARN_ON_ONCE
  2025-06-05  8:53 [PATCH] dma-buf: fix compare in WARN_ON_ONCE Christian König
  2025-06-10 14:07 ` Christian König
@ 2025-06-10 14:17 ` Tvrtko Ursulin
  1 sibling, 0 replies; 3+ messages in thread
From: Tvrtko Ursulin @ 2025-06-10 14:17 UTC (permalink / raw)
  To: Christian König, dan.carpenter, sumit.semwal, linux-media,
	dri-devel, linaro-mm-sig
  Cc: Christian König


On 05/06/2025 09:53, Christian König wrote:
> Smatch pointed out this trivial typo:
> 	drivers/dma-buf/dma-buf.c:1123 dma_buf_map_attachment()
> 	warn: passing positive error code '16' to 'ERR_PTR'
> 
> drivers/dma-buf/dma-buf.c
>      1113         dma_resv_assert_held(attach->dmabuf->resv);
>      1114
>      1115         if (dma_buf_pin_on_map(attach)) {
>      1116                 ret = attach->dmabuf->ops->pin(attach);
>      1117                 /*
>      1118                  * Catch exporters making buffers inaccessible even when
>      1119                  * attachments preventing that exist.
>      1120                  */
>      1121                 WARN_ON_ONCE(ret == EBUSY);
>                                               ^^^^^
> This was probably intended to be -EBUSY?
> 
>      1122                 if (ret)
> --> 1123                         return ERR_PTR(ret);
>                                                  ^^^
> Otherwise we will eventually crash.
> 
>      1124         }
>      1125
>      1126         sg_table = attach->dmabuf->ops->map_dma_buf(attach, direction);
>      1127         if (!sg_table)
>      1128                 sg_table = ERR_PTR(-ENOMEM);
>      1129         if (IS_ERR(sg_table))
>      1130                 goto error_unpin;
>      1131
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/dma-buf/dma-buf.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 0c48d41dd5eb..451714008e8a 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -1060,7 +1060,7 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
>   		 * Catch exporters making buffers inaccessible even when
>   		 * attachments preventing that exist.
>   		 */
> -		WARN_ON_ONCE(ret == EBUSY);
> +		WARN_ON_ONCE(ret == -EBUSY);
>   		if (ret)
>   			return ERR_PTR(ret);
>   	}

Thread bump FTW ;)

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>

Regards,

Tvrtko


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-10 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-05  8:53 [PATCH] dma-buf: fix compare in WARN_ON_ONCE Christian König
2025-06-10 14:07 ` Christian König
2025-06-10 14:17 ` Tvrtko Ursulin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).