On 9/14/26 23:22, Davidlohr Bueso wrote:
> dma_buf_phys_vec_to_sgt() asserts the reservation lock before its
> NULL checks run. Validate first, then assert.
>
> Fixes: 3aa31a8bb11e ("dma-buf: provide phys_vec to scatter-gather mapping
> routine")
> Signed-off-by: Davidlohr Bueso <[email protected]>
Good catch, but in general please put bug fixes as first one in a patch set.
Reviewed-by: Christian König <[email protected]>
Regards,
Christian.
> ---
> drivers/dma-buf/dma-buf-mapping.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-buf-mapping.c
> b/drivers/dma-buf/dma-buf-mapping.c
> index 833be519e1e6..12674d89b23e 100644
> --- a/drivers/dma-buf/dma-buf-mapping.c
> +++ b/drivers/dma-buf/dma-buf-mapping.c
> @@ -111,12 +111,12 @@ struct sg_table *dma_buf_phys_vec_to_sgt(struct
> dma_buf_attachment *attach,
> size_t i;
> int ret;
>
> - dma_resv_assert_held(attach->dmabuf->resv);
> -
> if (WARN_ON(!attach || !attach->dmabuf || !provider))
> /* This function is supposed to work on MMIO memory only */
> return ERR_PTR(-EINVAL);
>
> + dma_resv_assert_held(attach->dmabuf->resv);
> +
> dma = kzalloc_obj(*dma);
> if (!dma)
> return ERR_PTR(-ENOMEM);
> --
> 2.39.5
>