]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/scsi-qla4xxx-avoid-freeing-unallocated-dma-memory.patch
Linux 4.9.181
[thirdparty/kernel/stable-queue.git] / queue-4.4 / scsi-qla4xxx-avoid-freeing-unallocated-dma-memory.patch
1 From 8256f43fcb13e186302a89124f75ed439fa263ba Mon Sep 17 00:00:00 2001
2 From: Arnd Bergmann <arnd@arndb.de>
3 Date: Fri, 22 Mar 2019 15:25:03 +0100
4 Subject: scsi: qla4xxx: avoid freeing unallocated dma memory
5
6 [ Upstream commit 608f729c31d4caf52216ea00d20092a80959256d ]
7
8 Clang -Wuninitialized notices that on is_qla40XX we never allocate any DMA
9 memory in get_fw_boot_info() but attempt to free it anyway:
10
11 drivers/scsi/qla4xxx/ql4_os.c:5915:7: error: variable 'buf_dma' is used uninitialized whenever 'if' condition is false
12 [-Werror,-Wsometimes-uninitialized]
13 if (!(val & 0x07)) {
14 ^~~~~~~~~~~~~
15 drivers/scsi/qla4xxx/ql4_os.c:5985:47: note: uninitialized use occurs here
16 dma_free_coherent(&ha->pdev->dev, size, buf, buf_dma);
17 ^~~~~~~
18 drivers/scsi/qla4xxx/ql4_os.c:5915:3: note: remove the 'if' if its condition is always true
19 if (!(val & 0x07)) {
20 ^~~~~~~~~~~~~~~~~~~
21 drivers/scsi/qla4xxx/ql4_os.c:5885:20: note: initialize the variable 'buf_dma' to silence this warning
22 dma_addr_t buf_dma;
23 ^
24 = 0
25
26 Skip the call to dma_free_coherent() here.
27
28 Fixes: 2a991c215978 ("[SCSI] qla4xxx: Boot from SAN support for open-iscsi")
29 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
30 Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
31 Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
32 Signed-off-by: Sasha Levin <sashal@kernel.org>
33 ---
34 drivers/scsi/qla4xxx/ql4_os.c | 2 +-
35 1 file changed, 1 insertion(+), 1 deletion(-)
36
37 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
38 index c158967b59d7b..d220b4f691c77 100644
39 --- a/drivers/scsi/qla4xxx/ql4_os.c
40 +++ b/drivers/scsi/qla4xxx/ql4_os.c
41 @@ -5939,7 +5939,7 @@ static int get_fw_boot_info(struct scsi_qla_host *ha, uint16_t ddb_index[])
42 val = rd_nvram_byte(ha, sec_addr);
43 if (val & BIT_7)
44 ddb_index[1] = (val & 0x7f);
45 -
46 + goto exit_boot_info;
47 } else if (is_qla80XX(ha)) {
48 buf = dma_alloc_coherent(&ha->pdev->dev, size,
49 &buf_dma, GFP_KERNEL);
50 --
51 2.20.1
52