Re: [syzbot] WARNING in dma_map_sgtable (2)

From: Dan Carpenter
Date: Mon May 30 2022 - 11:50:55 EST


On Mon, May 30, 2022 at 10:45:42PM +0800, Hillf Danton wrote:
> To queisce the warning, make udmabuf misc device dma capable by default.
>
> #syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 7e062cda7d90
>
> --- y/drivers/dma-buf/udmabuf.c
> +++ u/drivers/dma-buf/udmabuf.c
> @@ -273,6 +273,14 @@ static long udmabuf_create(struct miscde
> if (IS_ERR(buf)) {
> ret = PTR_ERR(buf);
> goto err;
> + } else {
> + struct device *dev = ubuf->device->this_device;
> +
> + if (!dev->dma_mask) {
> + ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
> + if (ret)
> + goto err;
> + }
> }
>
> flags = 0;

Unrelated to your patch. In this function do we not need to cleanup if
dma_buf_fd(buf, flags); fails?

After dma_buf_fd() then the fd is exported so we can't clean up, but it
should be okay to clean up if dma_buf_fd() fails.

regards,
dan carpenter