The local variable 'sg' should be initialized in the failure path of mvumi_make_sgl(), otherwise the following build warning is triggered: In file included from include/linux/pci-dma-compat.h:8, from include/linux/pci.h:2408, from drivers/scsi/mvumi.c:13: drivers/scsi/mvumi.c: In function 'mvumi_queue_command': include/linux/dma-mapping.h:608:34: warning: 'sg' may be used uninitialized in this function +[-Wmaybe-uninitialized] #define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, 0) ^~~~~~~~~~~~~~~~~~ drivers/scsi/mvumi.c:192:22: note: 'sg' was declared here struct scatterlist *sg; ^~ Fixed it by removing the local variable reference in failure path. Cc: Christoph Hellwig <hch@xxxxxx> Cc: Bart Van Assche <bvanassche@xxxxxxx> Cc: Ewan D. Milne <emilne@xxxxxxxxxx> Fixes: 350d66a72adc ("scsi: mvumi: use sg helper to iterate over scatterlist") Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> --- drivers/scsi/mvumi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c index 0022cd31500a..53f3563aca22 100644 --- a/drivers/scsi/mvumi.c +++ b/drivers/scsi/mvumi.c @@ -217,7 +217,7 @@ static int mvumi_make_sgl(struct mvumi_hba *mhba, struct scsi_cmnd *scmd, dev_err(&mhba->pdev->dev, "sg count[0x%x] is bigger than max sg[0x%x].\n", *sg_count, mhba->max_sge); - dma_unmap_sg(&mhba->pdev->dev, sg, sgnum, + dma_unmap_sg(&mhba->pdev->dev, scsi_sglist(scmd), sgnum, scmd->sc_data_direction); return -1; } -- 2.20.1