dma-buf: Fix static checker warning
authorJianxin Xiong <jianxin.xiong@intel.com>
Tue, 3 Nov 2020 03:51:58 +0000 (19:51 -0800)
committerChristian König <christian.koenig@amd.com>
Thu, 5 Nov 2020 15:58:19 +0000 (16:58 +0100)
Here is the warning message:

drivers/dma-buf/dma-buf.c:917 dma_buf_map_attachment()
error: 'sg_table' dereferencing possible ERR_PTR()

Fix by adding error checking before dereferencing the pointer.

Fixes: ac80cd17a615 ("dma-buf: Clarify that dma-buf sg lists are page aligned")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jianxin Xiong <jianxin.xiong@intel.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/398485/
drivers/dma-buf/dma-buf.c

index 696b4ce..e63684d 100644 (file)
@@ -908,7 +908,7 @@ struct sg_table *dma_buf_map_attachment(struct dma_buf_attachment *attach,
        }
 
 #ifdef CONFIG_DMA_API_DEBUG
-       {
+       if (!IS_ERR(sg_table)) {
                struct scatterlist *sg;
                u64 addr;
                int len;