All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: qla4xxx: avoid freeing unallocated dma memory
@ 2019-03-22 14:25 Arnd Bergmann
  2019-03-22 15:25 ` Nathan Chancellor
  2019-03-26  2:16 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2019-03-22 14:25 UTC (permalink / raw)
  To: QLogic-Storage-Upstream, James E.J. Bottomley, Martin K. Petersen
  Cc: clang-built-linux, Nick Desaulniers, Nathan Chancellor,
	Arnd Bergmann, Manish Rangankar, Chengguang Xu,
	Johannes Thumshirn, linux-scsi, linux-kernel

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;
                          ^
                           = 0

Skip the call to dma_free_coherent() here.

Fixes: 2a991c215978 ("[SCSI] qla4xxx: Boot from SAN support for open-iscsi")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/scsi/qla4xxx/ql4_os.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 16a18d5d856f..daa884fa43f4 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -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);
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: qla4xxx: avoid freeing unallocated dma memory
  2019-03-22 14:25 [PATCH] scsi: qla4xxx: avoid freeing unallocated dma memory Arnd Bergmann
@ 2019-03-22 15:25 ` Nathan Chancellor
  2019-03-26  2:16 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2019-03-22 15:25 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: QLogic-Storage-Upstream, James E.J. Bottomley,
	Martin K. Petersen, clang-built-linux, Nick Desaulniers,
	Manish Rangankar, Chengguang Xu, Johannes Thumshirn, linux-scsi,
	linux-kernel

On Fri, Mar 22, 2019 at 03:25:03PM +0100, Arnd Bergmann wrote:
> 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;
>                           ^
>                            = 0
> 
> Skip the call to dma_free_coherent() here.
> 
> Fixes: 2a991c215978 ("[SCSI] qla4xxx: Boot from SAN support for open-iscsi")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

This is what I initially had but I guess I cared too much about that
debug print firing properly :) I like this better personally.

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

> ---
>  drivers/scsi/qla4xxx/ql4_os.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
> index 16a18d5d856f..daa884fa43f4 100644
> --- a/drivers/scsi/qla4xxx/ql4_os.c
> +++ b/drivers/scsi/qla4xxx/ql4_os.c
> @@ -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);
> -- 
> 2.20.0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] scsi: qla4xxx: avoid freeing unallocated dma memory
  2019-03-22 14:25 [PATCH] scsi: qla4xxx: avoid freeing unallocated dma memory Arnd Bergmann
  2019-03-22 15:25 ` Nathan Chancellor
@ 2019-03-26  2:16 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2019-03-26  2:16 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: QLogic-Storage-Upstream, James E.J. Bottomley,
	Martin K. Petersen, clang-built-linux, Nick Desaulniers,
	Nathan Chancellor, Manish Rangankar, Chengguang Xu,
	Johannes Thumshirn, linux-scsi, linux-kernel


Arnd,

> Clang -Wuninitialized notices that on is_qla40XX we never allocate any
> DMA memory in get_fw_boot_info() but attempt to free it anyway:

Applied to 5.2/scsi-queue, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-26  2:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22 14:25 [PATCH] scsi: qla4xxx: avoid freeing unallocated dma memory Arnd Bergmann
2019-03-22 15:25 ` Nathan Chancellor
2019-03-26  2:16 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.