diff mbox series

[7/7] qla2xxx: Always check the return value of qla24xx_get_isp_stats()

Message ID 20210316035655.2835-8-bvanassche@acm.org (mailing list archive)
State Superseded
Headers show
Series qla2xxx patches for kernel v5.12 and v5.13 | expand

Commit Message

Bart Van Assche March 16, 2021, 3:56 a.m. UTC
This patch fixes the following Coverity warning:

    CID 361199 (#1 of 1): Unchecked return value (CHECKED_RETURN)
    3. check_return: Calling qla24xx_get_isp_stats without checking return
    value (as is done elsewhere 4 out of 5 times).

Cc: Quinn Tran <qutran@marvell.com>
Cc: Mike Christie <michael.christie@oracle.com>
Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
Cc: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/qla2xxx/qla_attr.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Daniel Wagner March 16, 2021, 8:48 a.m. UTC | #1
On Mon, Mar 15, 2021 at 08:56:55PM -0700, Bart Van Assche wrote:
>  		/* reset firmware statistics */
> -		qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
> +		rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
> +		WARN_ONCE(rval != QLA_SUCCESS, "rval = %d\n", rval);

ql_log() instead of WARN_ONCE? The function uses ql_log() if
dma_alloc_coherrent() fails a few lines above.
Himanshu Madhani March 16, 2021, 4:30 p.m. UTC | #2
> On Mar 15, 2021, at 10:56 PM, Bart Van Assche <bvanassche@acm.org> wrote:
> 
> This patch fixes the following Coverity warning:
> 
>    CID 361199 (#1 of 1): Unchecked return value (CHECKED_RETURN)
>    3. check_return: Calling qla24xx_get_isp_stats without checking return
>    value (as is done elsewhere 4 out of 5 times).
> 
> Cc: Quinn Tran <qutran@marvell.com>
> Cc: Mike Christie <michael.christie@oracle.com>
> Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
> Cc: Daniel Wagner <dwagner@suse.de>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/scsi/qla2xxx/qla_attr.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
> index 63391c9be05d..ad57111f8cb9 100644
> --- a/drivers/scsi/qla2xxx/qla_attr.c
> +++ b/drivers/scsi/qla2xxx/qla_attr.c
> @@ -2864,6 +2864,8 @@ qla2x00_reset_host_stats(struct Scsi_Host *shost)
> 	vha->qla_stats.jiffies_at_last_reset = get_jiffies_64();
> 
> 	if (IS_FWI2_CAPABLE(ha)) {
> +		int rval;
> +
> 		stats = dma_alloc_coherent(&ha->pdev->dev,
> 		    sizeof(*stats), &stats_dma, GFP_KERNEL);
> 		if (!stats) {
> @@ -2873,7 +2875,8 @@ qla2x00_reset_host_stats(struct Scsi_Host *shost)
> 		}
> 
> 		/* reset firmware statistics */
> -		qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
> +		rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
> +		WARN_ONCE(rval != QLA_SUCCESS, "rval = %d\n", rval);
> 
> 		dma_free_coherent(&ha->pdev->dev, sizeof(*stats),
> 		    stats, stats_dma);

Looks Good.

Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>

--
Himanshu Madhani	 Oracle Linux Engineering
Bart Van Assche March 16, 2021, 8:40 p.m. UTC | #3
On 3/16/21 1:48 AM, Daniel Wagner wrote:
> On Mon, Mar 15, 2021 at 08:56:55PM -0700, Bart Van Assche wrote:
>>  		/* reset firmware statistics */
>> -		qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
>> +		rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
>> +		WARN_ONCE(rval != QLA_SUCCESS, "rval = %d\n", rval);
> 
> ql_log() instead of WARN_ONCE? The function uses ql_log() if
> dma_alloc_coherrent() fails a few lines above.

Hi Daniel,

I will make that change.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 63391c9be05d..ad57111f8cb9 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -2864,6 +2864,8 @@  qla2x00_reset_host_stats(struct Scsi_Host *shost)
 	vha->qla_stats.jiffies_at_last_reset = get_jiffies_64();
 
 	if (IS_FWI2_CAPABLE(ha)) {
+		int rval;
+
 		stats = dma_alloc_coherent(&ha->pdev->dev,
 		    sizeof(*stats), &stats_dma, GFP_KERNEL);
 		if (!stats) {
@@ -2873,7 +2875,8 @@  qla2x00_reset_host_stats(struct Scsi_Host *shost)
 		}
 
 		/* reset firmware statistics */
-		qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
+		rval = qla24xx_get_isp_stats(base_vha, stats, stats_dma, BIT_0);
+		WARN_ONCE(rval != QLA_SUCCESS, "rval = %d\n", rval);
 
 		dma_free_coherent(&ha->pdev->dev, sizeof(*stats),
 		    stats, stats_dma);