]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
scsi: gdth: Only call dma_free_coherent when buf is not NULL in ioc_general
authorNathan Chancellor <natechancellor@gmail.com>
Thu, 7 Mar 2019 23:18:39 +0000 (16:18 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 26 Mar 2019 02:22:44 +0000 (22:22 -0400)
When building with -Wsometimes-uninitialized, Clang warns:

drivers/scsi/gdth.c:3662:6: warning: variable 'paddr' is used
uninitialized whenever 'if' condition is false
[-Wsometimes-uninitialized]

Don't attempt to call dma_free_coherent when buf is NULL (meaning that
we never called dma_alloc_coherent and initialized paddr), which avoids
this warning.

Link: https://github.com/ClangBuiltLinux/linux/issues/402
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/gdth.c

index e7f1dd4f3b66060391024f25d6cfe1da1d0459df..0ca9b4393770880b68875c08509570ef1f135add 100644 (file)
@@ -3697,8 +3697,9 @@ static int ioc_general(void __user *arg, char *cmnd)
 
        rval = 0;
 out_free_buf:
-       dma_free_coherent(&ha->pdev->dev, gen.data_len + gen.sense_len, buf,
-                       paddr);
+       if (buf)
+               dma_free_coherent(&ha->pdev->dev, gen.data_len + gen.sense_len,
+                                 buf, paddr);
        return rval;
 }