diff mbox series

[6/8] qla2xxx: Fix memory leak when sending I/O fails

Message ID 20191105150657.8092-7-hmadhani@marvell.com (mailing list archive)
State Mainlined
Commit 2f856d4e8c23f5ad5221f8da4a2f22d090627f19
Headers show
Series qla2xxx: Bug Fixes for the driver | expand

Commit Message

Himanshu Madhani Nov. 5, 2019, 3:06 p.m. UTC
From: Arun Easi <aeasi@marvell.com>

On heavy loads, a memory leak of the srb_t structure is observed.
This would make the qla2xxx_srbs cache gobble up memory.

Fixes: 219d27d7147e0 ("scsi: qla2xxx: Fix race conditions in the code for aborting SCSI commands")
Cc: stable@vger.kernel.org # 5.2
Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
---
 drivers/scsi/qla2xxx/qla_os.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Ewan Milne Nov. 5, 2019, 3:20 p.m. UTC | #1
On Tue, 2019-11-05 at 07:06 -0800, Himanshu Madhani wrote:
> From: Arun Easi <aeasi@marvell.com>
> 
> On heavy loads, a memory leak of the srb_t structure is observed.
> This would make the qla2xxx_srbs cache gobble up memory.
> 
> Fixes: 219d27d7147e0 ("scsi: qla2xxx: Fix race conditions in the code for aborting SCSI commands")
> Cc: stable@vger.kernel.org # 5.2
> Signed-off-by: Arun Easi <aeasi@marvell.com>
> Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
> ---
>  drivers/scsi/qla2xxx/qla_os.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index b59d579834ea..b513008042fb 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -909,6 +909,8 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
>  
>  qc24_host_busy_free_sp:
>  	sp->free(sp);
> +	CMD_SP(cmd) = NULL;
> +	qla2x00_rel_sp(sp);
>  
>  qc24_target_busy:
>  	return SCSI_MLQUEUE_TARGET_BUSY;
> @@ -992,6 +994,8 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd,
>  
>  qc24_host_busy_free_sp:
>  	sp->free(sp);
> +	CMD_SP(cmd) = NULL;
> +	qla2xxx_rel_qpair_sp(sp->qpair, sp);
>  
>  qc24_target_busy:
>  	return SCSI_MLQUEUE_TARGET_BUSY;

Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Himanshu Madhani Nov. 18, 2019, 8:25 p.m. UTC | #2
Hi Martin, 

> On Nov 5, 2019, at 9:06 AM, Himanshu Madhani <hmadhani@marvell.com> wrote:
> 
> From: Arun Easi <aeasi@marvell.com>
> 
> On heavy loads, a memory leak of the srb_t structure is observed.
> This would make the qla2xxx_srbs cache gobble up memory.
> 
> Fixes: 219d27d7147e0 ("scsi: qla2xxx: Fix race conditions in the code for aborting SCSI commands")
> Cc: stable@vger.kernel.org # 5.2
> Signed-off-by: Arun Easi <aeasi@marvell.com>
> Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
> ---
> drivers/scsi/qla2xxx/qla_os.c | 4 ++++
> 1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index b59d579834ea..b513008042fb 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -909,6 +909,8 @@ qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
> 
> qc24_host_busy_free_sp:
> 	sp->free(sp);
> +	CMD_SP(cmd) = NULL;
> +	qla2x00_rel_sp(sp);
> 
> qc24_target_busy:
> 	return SCSI_MLQUEUE_TARGET_BUSY;
> @@ -992,6 +994,8 @@ qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd,
> 
> qc24_host_busy_free_sp:
> 	sp->free(sp);
> +	CMD_SP(cmd) = NULL;
> +	qla2xxx_rel_qpair_sp(sp->qpair, sp);
> 
> qc24_target_busy:
> 	return SCSI_MLQUEUE_TARGET_BUSY;
> -- 
> 2.12.0
> 

We found this patch to have introduced regression of double free. Please revert this patch in 5.5/scsi-queue and not needed with the patch 5 included in the series. 

Thanks,
Himanshu
Martin K. Petersen Nov. 19, 2019, 5:02 a.m. UTC | #3
Himanshu,

> We found this patch to have introduced regression of double
> free. Please revert this patch in 5.5/scsi-queue and not needed with
> the patch 5 included in the series.

Reverted in 5.5/scsi-queue, thanks.
diff mbox series

Patch

diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index b59d579834ea..b513008042fb 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -909,6 +909,8 @@  qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 
 qc24_host_busy_free_sp:
 	sp->free(sp);
+	CMD_SP(cmd) = NULL;
+	qla2x00_rel_sp(sp);
 
 qc24_target_busy:
 	return SCSI_MLQUEUE_TARGET_BUSY;
@@ -992,6 +994,8 @@  qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd,
 
 qc24_host_busy_free_sp:
 	sp->free(sp);
+	CMD_SP(cmd) = NULL;
+	qla2xxx_rel_qpair_sp(sp->qpair, sp);
 
 qc24_target_busy:
 	return SCSI_MLQUEUE_TARGET_BUSY;