scsi: qla4xxx: avoid freeing unallocated dma memory
Subsystems (2)
PATCH 1/1 scsi: qla4xxx: avoid freeing unallocated dma memory
Clang -Wuninitialized notices that on is_qla40XX we never allocate any DMA memory in get_fw_boot_info() but attempt to free it anyway:
drivers/scsi/qla4xxx/ql4_os.c:5915:7: error: variable 'buf_dma' is used uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
if (!(val & 0x07)) {
^~~~~~~~~~~~~
drivers/scsi/qla4xxx/ql4_os.c:5985:47: note: uninitialized use occurs here
dma_free_coherent(&ha->pdev->dev, size, buf, buf_dma);
^~~~~~~
drivers/scsi/qla4xxx/ql4_os.c:5915:3: note: remove the 'if' if its condition is always true
if (!(val & 0x07)) {
^~~~~~~~~~~~~~~~~~~
drivers/scsi/qla4xxx/ql4_os.c:5885:20: note: initialize the variable 'buf_dma' to silence this warning
dma_addr_t buf_dma;
^
= 0Skip the call to dma_free_coherent() here.
--- drivers/scsi/qla4xxx/ql4_os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla4xxx/ql4_os.c +1 -1
@@ -5928,7 +5928,7 @@ static int get_fw_boot_info(struct scsi_qla_host *ha, uint16_t ddb_index[]) val =rd_nvram_byte (ha, sec_addr);if (val &BIT_7 ) ddb_index[1 ] = (val &0x7f ); - + goto exit_boot_info; }else if (is_qla80XX (ha)) { buf =dma_alloc_coherent (&ha->pdev->dev, size, &buf_dma,GFP_KERNEL );
Signature · 1 line
2.20.0
Quoted 18 lines · Arnd Bergmann
Clang -Wuninitialized notices that on
is_qla40XXwe never allocate any DMA memory inget_fw_boot_info()but attempt to free it anyway:
drivers/scsi/qla4xxx/ql4_os.c:5915:7: error: variable 'buf_dma' is used uninitialized whenever 'if' condition is false[-Werror,-Wsometimes-uninitialized] if (!(val & 0x07)) { ^~~~~~~~~~~~~ drivers/scsi/qla4xxx/ql4_os.c:5985:47: note: uninitialized use occurs here dma_free_coherent(&ha->pdev->dev, size, buf, buf_dma); ^~~~~~~ drivers/scsi/qla4xxx/ql4_os.c:5915:3: note: remove the 'if' if its condition is always true if (!(val & 0x07)) { ^~~~~~~~~~~~~~~~~~~ drivers/scsi/qla4xxx/ql4_os.c:5885:20: note: initialize the variable 'buf_dma' to silence this warning dma_addr_t buf_dma; ^ = 0
Quoted 4 lines
Skip the call to
dma_free_coherent()here.Fixes 2a991c215978 ("[SCSI] qla4xxx: Boot from SAN support for open-iscsi")Signed-off-by Arnd Bergmann <[email protected]>
This is what I initially had but I guess I cared too much about that debug print firing properly :) I like this better personally.
Quoted 20 lines
--- drivers/scsi/qla4xxx/ql4_os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/scsi/qla4xxx/ql4_os.c +1
-1@@ -5928,7 +5928,7 @@ static int get_fw_boot_info(struct scsi_qla_host *ha, uint16_t ddb_index[]) val =rd_nvram_byte (ha, sec_addr);if (val &BIT_7 ) ddb_index[1 ] = (val &0x7f ); - + goto exit_boot_info; }else if (is_qla80XX (ha)) { buf =dma_alloc_coherent (&ha->pdev->dev, size, &buf_dma,GFP_KERNEL );Signature · 1 line
2.20.0
Martin K. Petersen
AppliedArnd,
Quoted 2 lines
Clang -Wuninitialized notices that on
is_qla40XXwe never allocate any DMA memory inget_fw_boot_info()but attempt to free it anyway:
Applied to 5.2/scsi-queue, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering